Showing an estimated reading time at the top of a blog post is one of those small touches that quietly improves the reading experience. It tells visitors what they are committing to before they start, which helps some of them stay and read, and helps others decide to bookmark the post for later instead of bouncing halfway through. Most tutorials recommend installing a plugin. You do not need one. A short PHP snippet and a shortcode placed in your theme’s post template is enough to show an automatic reading time on every post on your site, current and future, with no per post setup, and no ongoing plugin to maintain.
The method below is plain WordPress, so it works regardless of which theme you are running. Since I build mainly on Divi, I am using it as the example for where to place the shortcode, and including a separate section further down for adding it specifically through Divi’s page builder, but the core code works exactly the same way on Astra, GeneratePress, OceanWP, or any other theme.

How Reading Time Is Actually Calculated
Every reading time feature, plugin or custom code, works the same simple way underneath. It counts the words in the post, then divides that number by an assumed reading speed, measured in words per minute. A 1,000 word post at 200 words per minute comes out to 5 minutes. That is the entire calculation. There is no analysis of sentence complexity or vocabulary difficulty involved in the basic version, just word count divided by a speed assumption.
The speed assumption is where a little judgment comes in. Reported average reading speeds vary across sources, generally somewhere between 200 and 275 words per minute, and the right number for your site depends on what you write about. Faster speeds make sense for light, conversational content. Slower speeds make more sense for technical writing, since readers tend to slow down for code, configuration steps, and concepts that need re-reading. I write technical WordPress and SEO tutorials, so I am using 200 words per minute here. If most of your content is lighter reading, 225 to 250 is a reasonable adjustment.
Step 1: Add the PHP Function
This function counts the words in a post’s content and works out the reading time. It is plain WordPress code, with nothing theme specific in it, so it belongs in a place that runs site wide rather than inside any particular page builder. You have two options for where to add it.
Recommended: the Code Snippets plugin. This keeps your custom code separate from your theme entirely. If something ever needs to be disabled or removed, you do it from one screen, with no risk to your site’s core files. Install the free Code Snippets plugin, add a new snippet, and paste in the following:
function get_post_reading_time() {
$content = get_post_field( 'post_content', get_the_ID() );
$word_count = str_word_count( strip_tags( $content ) );
$reading_time = ceil( $word_count / 200 );
return $reading_time;
}
add_shortcode( 'reading_time', 'get_post_reading_time' );
To change the estimated reading speed, replace 200 with another value such as 225 or 250 depending on your audience.
Set the snippet to run everywhere, then activate it.
Alternative: your child theme’s functions.php file. If you would rather not add another plugin, you can paste the same function directly into your child theme’s functions.php file instead, through Appearance > Theme File Editor. This works exactly the same way, but a quick word of caution: a typo in functions.php can take your entire site down until it is fixed, since this file loads on every single page. Always make a backup before editing it directly, and if you are not fully comfortable working in this file, the Code Snippets plugin is the safer choice. Avoid adding custom code directly to a parent theme, as theme updates will overwrite your changes. If you’re not using a child theme, the Code Snippets plugin is the safer option.
Here is what the function is actually doing, line by line:
- get_post_field(‘post_content’, get_the_ID()) pulls the raw content of whichever post is currently being viewed.
- strip_tags() removes HTML markup from that content first, so tags like <p> or <img> do not get miscounted as words.
- str_word_count() counts the actual words left after the tags are stripped out.
- ceil($word_count / 200) divides by 200 words per minute and rounds up, so a post that comes out to 4.2 minutes displays as 5, not as a decimal.
- add_shortcode(‘reading_time’, …) registers a [reading_time] shortcode that outputs just the number, ready to drop in anywhere shortcodes are supported.
Step 2: Display the Shortcode in Your Theme
With the function in place, the shortcode 9 will now output a number anywhere shortcodes are rendered. Exactly where you place it depends on your theme and how its single post template works. A few common approaches:
- Classic and block themes without a page builder: most themes support shortcodes directly inside widgets, and many also render them inside template areas if your theme uses a template tag like
do_shortcode()in its single.php file. If you are comfortable editing theme files, addingecho do_shortcode('[reading_time] min read');near your post meta in single.php works on virtually any classic theme. - Block themes and the Block Editor: add a Shortcode block to your post template inside Site Editor, near where the date or author is shown, and place [reading_time] min read inside it.
- Page builders generally: most page builders, Divi included, have either a dedicated Shortcode element or let you drop a shortcode into a regular text element. Add it to your site wide post template, not to individual posts, so every post picks it up automatically.
Adding It in Divi Specifically
Since I build primarily on Divi, here is exactly where this goes if that is your setup too.
Where to find this: Go to Divi > Theme Builder, and open your Blog Post Template, the template Divi uses to display single posts.
One thing worth knowing before you start: the Post Title module and the Post Meta module in Divi are both system modules that pull their content directly from WordPress, the title, date, author, and category. There is no field inside either one where you can type or insert a shortcode, so the reading time cannot be appended directly into the same line as your title or your existing meta text. It needs its own separate Text module instead, placed near the title or meta area, not inside it.
Add a new Text module just below your Post Title or Post Meta module, wherever you want the reading time to appear. Inside that Text module, type:
[reading_time] min read
Save the template. Visit any published post on your site, and the calculated reading time should appear in that spot, with no further setup needed on a per post basis. Keeping it as its own line, rather than trying to force it into the same line as your date and category, also tends to look cleaner, especially on mobile where a single crowded meta line can wrap awkwardly.
A quick note if you also want to try this through Divi’s Dynamic Content system instead of a plain Text module: Divi 5 lets you build dynamic content sources, but these are designed around displaying existing field values such as custom fields, not running a calculation like this one. The shortcode and Text module approach above is the reliable method. If a cleaner dynamic content based version becomes possible in a future Divi update, this section will be updated to reflect it.
A Note on Accuracy
This method counts words in the post content field, which means it will undercount posts that lean heavily on images, embedded videos, or content rendered through blocks and shortcodes rather than plain text, since those do not contribute many countable words. For most blog content, especially text based tutorials and articles, this is a non issue. If a particular post is unusually image heavy or video heavy relative to its actual reading time, treat the displayed number as a rough estimate for that post rather than an exact one.
Frequently Asked Questions
Does this work with any WordPress theme, or only Divi?
The PHP function itself is plain WordPress code and works with any theme. Divi is used here as the example for displaying the shortcode, through a Text module in the Blog Post Template, but the same shortcode can be placed through a Shortcode block in block themes, or directly in a classic theme’s single.php file using do_shortcode.
Will this slow down my site?
No. The word count calculation runs once when the page loads and is a simple, lightweight PHP operation. It does not add any external requests, scripts, or stylesheets, and has no measurable effect on page speed or Core Web Vitals.
What words per minute speed should I use?
General web content commonly uses a value somewhere between 200 and 250 words per minute. Slower speeds, closer to 200, are a better fit for technical or instructional content, since readers tend to move through it more carefully. Faster speeds, closer to 250, suit lighter, more conversational posts. Pick one value and use it consistently across your site, since switching between different speeds on different posts makes the numbers harder to trust.
Does this work on existing posts, or only new ones?
It works on every post immediately, including ones already published. The shortcode calculates the reading time live, based on each post’s actual content, every time the page loads. There is no need to edit or republish any existing posts.
Can I change the displayed text, like showing “minute” instead of “min”?
Yes. The shortcode only outputs the number. Everything else, the word “min,” “minute,” “read,” or any other wording around it, is just regular text typed directly alongside the shortcode, so you can phrase it however fits your site.


