Show readers an automatic “5 min read” message based on the amount of text in a blog post.
Steps
- Add the code below to your theme’s
functions.php. - Save the changes.
- Open a blog post.
- The estimated reading time will appear before the post content.
/**
* Add estimated reading time to WordPress posts
*/
function custom_estimated_reading_time( $content ) {
if ( ! is_single() || ! is_main_query() || ! in_the_loop() ) {
return $content;
}
$word_count = str_word_count( wp_strip_all_tags( $content ) );
// Average reading speed: 200 words per minute.
$reading_time = max( 1, ceil( $word_count / 200 ) );
$reading_text = '<div class="estimated-reading-time">';
$reading_text .= 'Estimated reading time: ' . $reading_time . ' min read';
$reading_text .= '</div>';
return $reading_text . $content;
}
add_filter( 'the_content', 'custom_estimated_reading_time' );
Tested on
WordPress 6.8
Reported by the author on September 24, 2026. WPFolks has not verified this.
Not tested against WordPress 7.1.4. It may still work.
