The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Add Estimated Reading Time to WordPress Posts

Shared by Amit Dholiya · September 24, 2026 · @the_content

28 views
1 upvote
Back to Snippets

Show readers an automatic “5 min read” message based on the amount of text in a blog post.

Steps

  1. Add the code below to your theme’s functions.php.
  2. Save the changes.
  3. Open a blog post.
  4. 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.

Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments

Proudly supported by