Astra_Ext_Blog_Pro_Markup::calculate_reading_time( int $post_id )

Calculate reading time.


Description


Parameters

$post_id

(int) (Required) Post content.


Return

(int) read time.


Source

File: addons/blog-pro/classes/class-astra-ext-blog-pro-markup.php

		public function calculate_reading_time( $post_id ) {

			$post_content       = get_post_field( 'post_content', $post_id );
			$stripped_content   = strip_shortcodes( $post_content );
			$strip_tags_content = wp_strip_all_tags( $stripped_content );
			$word_count         = count( preg_split( '/\s+/', $strip_tags_content ) );
			$reading_time       = ceil( $word_count / 220 );

			return $reading_time;
		}

Changelog

Changelog
Version Description
1.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.