Skip to content

Instantly share code, notes, and snippets.

@robertoandres24
Created April 10, 2019 19:32
Show Gist options
  • Save robertoandres24/cceef8423db22a0d82c656be740ab664 to your computer and use it in GitHub Desktop.
Save robertoandres24/cceef8423db22a0d82c656be740ab664 to your computer and use it in GitHub Desktop.
Brian Cray's original, for Wordpress:
<?php
$mycontent = $post->post_content; // wordpress users only
$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');
?>
<p>Estimated reading time: <?php echo $est; ?></p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment