Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nschaeferhoff/41b2b2466117b12bd9b53f6e154af76c to your computer and use it in GitHub Desktop.
Save nschaeferhoff/41b2b2466117b12bd9b53f6e154af76c to your computer and use it in GitHub Desktop.
function reading_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$readingtime = ceil($word_count / 200);
if ($readingtime == 1) {
$timer = " minute";
} else {
$timer = " minutes";
}
$totalreadingtime = $readingtime . $timer;
return $totalreadingtime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment