It can be very useful for your readers to know how much time they’ll spend on an article before they engage. We can estimate the total reading time based on the amount of text of the article and considering the average human read speed. 

So here goes a very simple snippet to display the reading time of your posts on WordPress based on the text length. In our example, we assumed that an average of 200 words are read per minute.

In the following, the ceil function rounds any real number to the closest greater whole number, and str_word_count counts the number of words in the text passed as a parameter. In your theme folder, edit the functions.php adding this code at the bottom.

Now in the loop of your blog template you can display the read time for each article.

The result can be seen on the index of our coding section or on BabyFactory.

Author: Marcio

Webdesigner @ Yhello

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.