WordPress – Estimated Reading Time

I have a theme coming out soon that displays the ‘estimated reading time’ for each blog post on the homepage.

The theme is inspired by the new blogging service Medium – but I first saw the idea mentioned on Brian Crays blog. I thought it was a really nice thing to add – and the idea that people are more likely to read an article when they know how long it is was quite appealing (in fact I am now wondering if I should add it on this site as well).

Anyway – the code was quite simple – so I turned it into an easily reusable function, as seen below.

All the code does is calculate the number of words in the article, and then assign a number of seconds per word. It’s very simple but gives quite nice results.

 * Estimate time required to read the article
 * @return string
function bm_estimated_reading_time() {

	$post = get_post();

	$words = str_word_count( strip_tags( $post->post_content ) );
	$minutes = floor( $words / 120 );
	$seconds = floor( $words % 120 / ( 120 / 60 ) );

	if ( 1
<p>I'll be posting about the theme in question the future - so I'll point it out then 🙂</p>
<p class="message information">The theme in question is called Kent and it's now available to buy on WordPress.com. You can <a href="http://kentdemo.wordpress.com/">check out the Kent demo here</a>.</p>

Was it good/ useful/ a load of old rubbish? Let me know on Mastodon, or BlueSky (or Twitter X if you must).

Link to this page

Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.

WordPress News

The latest WordPress updates from the WPBriefs Podcast.

Related Posts

11 Jul 2014

Localised Estimated Reading Time

So a few people have been writing about my estimated reading time function recently. In particular – it got mentioned on WPTavern in a post all about adding an Estimated Reading Time to your theme.Then I got this tweet: Hey...
31 May 2007

WordPress tips and tricks – functions.php

Functions.php is a little known wordpress template file. Not many themes take advantage of it but , used properly, it can be incredibly powerful. The file can be used as a way to add your own functions to wordpress themes...
13 May 2010

6 Tips to Build Better WordPress Themes

If you want to make WordPress themes, for clients, to release for free or to sell, then there are a lot of factors you need to take into consideration. Below are some hints and tips that should help ease your...
22 Nov 2014

WordPress 4.1 Improvements for Theme Developers

WordPress 4.1 is bringing with it a couple of cool new additions for theme developers. They’re things that are currently a bit messy to implement in themes. For me they are things that I do the same way in all...