reading

Show Estimated Reading Time at Post Meta

Want to tell your readers how long it will take an article to read completely? Insert the following code into the right file (e.g., single.php or page.php) in the right place (above post meta and below post title) in your theme. It counts total words in an article and calculates time by estimating that on average a reader can read 200 words in a minute.

<?php
$mycontent = $post->post_content;
            $word = str_word_count(strip_tags($mycontent));
            $m = floor($word / 200);
            $s = floor($word % 200 / (200 / 60));
            $est = $m . ' minute' . ($m == 1 ? '' : 's') . ', ' . $s . ' second' . ($s == 1 ? '' : 's');
?>