Skip to Content

estimated_reading_time()

Get the estimated reading time for a post.

PHP November 8, 2018

Usage

PHP
nebula()->estimated_reading_time($id);

Parameters

$id
(Optional) (Integer) The post to get reading time for
Default: Current post

Request or provide clarification »

Additional Notes

This returns the estimated reading time in minutes for an average of 250 words per minute reading speed.

Note: Be sure to hook custom fields into the Nebula word_count() function to get an accurate estimate!

Source File

Located in /libs/Functions.php on line 933.

No Hooks

This function does not have any filters or actions available. Request one?

Note: This function contains 1 to-do comment.

PHP
        public function estimated_reading_time($id=false){
            //@todo "Nebula" 0: Use null coalescing operator here if possible
            if ( empty($id) ){
                $id = get_the_ID();
            }

            $wpm = 250; //Words per minute reading speed
            $content = $this->word_count(array('id' => $id));

            return intval(round($content/$wpm));
        }

Override

This function can not be short-circuited with an override filter. Request one?