Skip to main content
Login Join
Snippet · PHP

Add Estimated Reading Time

Shared by Darshit Rajyaguru · May 8, 2026 · @the_content

46 views
1 upvote
Back to Snippets

Automatically calculate and display estimated reading time before post content based on average reading speed. Helps improve user engagement and content readability.

add_filter( 'the_content', 'wpf_add_reading_time' );
function wpf_add_reading_time( $content ) {
	if ( ! is_single() ) {
		return $content;
	}
	$word_count   = str_word_count( wp_strip_all_tags( $content ) );
	$reading_time = ceil( $word_count / 200 );
	$label = sprintf(
		'<p><strong>Estimated Reading Time:</strong> %d min</p>',
		$reading_time
	);
	return $label . $content;
}
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