WordPress

Add estimated Read Time

To add the read time on the content of the post on the site, add the below code to the functions.php file

//estimated reading time
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;
}

Then add the code on the required template file or inside the while loop

<?php echo reading_time(); ?>