January 31, 2024

Insert the Blog Post Read Time in WordPress with Code Snippets

Play Video

Incorporating the blog post read time into your WordPress website enhances user experience by providing a quick insight into the time commitment required for each post. This tutorial shows how to insert the blog post read time in WordPress using code snippets.

Blog Post Read Time in WordPress with Code Snippets Preview
Blog Post Read Time in WordPress with Code Snippets Preview

Prerequisites

Please make sure you have the following installed and activated:


Why Include Reading Time on Your WordPress Posts

Including the reading time on your WordPress posts offers several benefits:

  • Enhanced User Experience
    Displaying the estimated reading time helps users gauge how long it will take to read a post, allowing them to manage their time effectively. This feature is especially useful for readers who are on tight schedules or prefer quick reads.
  • Increased Engagement
    Knowing the reading time upfront can encourage visitors to start reading a post, particularly if the time commitment seems reasonable. It reduces the bounce rate as users are more likely to commit to reading when they know the duration.
  • Better Content Strategy
    By providing reading time, you can analyze which length of posts performs better with your audience. This insight helps in tailoring your content strategy to match user preferences.
  • Improved Credibility and Professionalism
    Adding reading time to your posts reflects a thoughtful and user-centric approach, enhancing the professional image of your website.
  • SEO Benefits|While reading time itself may not directly impact SEO, the increased user engagement and lower bounce rates indirectly boost your site’s SEO performance.

Instructions to Add the Read Time in WordPress to Your Blog Post

  1. Install and activate the Code Snippets plugin (Plugins > Add New Plugin > Search “Code Snippets”).
  2. Navigate to Code Snippets > Add New and copy the code below:
    function nestwise_calculate_reading_time( $content ) {
        $word_count = str_word_count( strip_tags( $content ) );
        $reading_time = ceil( $word_count / 200 );
        return $reading_time;
    }
    
    function nestwise_reading_time_shortcode() {
        global $post;
        $reading_time = nestwise_calculate_reading_time( $post->post_content );
        return '<span class="reading-time">Read Time: ' . $reading_time . ' minute(s)</span>';
    }
    
    add_shortcode( 'read-time', 'nestwise_reading_time_shortcode' );

    Source: Code Snippets

  3. Paste the code, and give your new snippet a title.
    Paste the code, and give your new snippet a titleTip

    Tip: Modify the word count value if needed. The default is set to 200 words equaling one minute.

  4. Click ‘Save Changes’ and activate the snippet.
  5. Edit your Elementor single post template or any WordPress post.
    Edit your Elementor single post template or any WordPress post
  6. Insert the shortcode [read-time] where you want the read time displayed.
    Insert the shortcode [read-time] where you want the read time displayed

Official Documentation


Read Time in WordPress – Conclusion

Adding a read time feature using a simple code snippet in WordPress is a straightforward process that significantly improves the functionality and user experience of your website. This tutorial guides you through each step, ensuring seamless integration.

Required Resources

Code Snippets Logo
Free Options
Credit to Web Squadron
Web Squadron is a popular YouTube channel dedicated to providing informative tutorials, tips, and insights on web development and design. With a strong focus on WordPress and website builders like Bricks Builder, the channel aims to help users of all skill levels, from beginners to advanced developers, create and optimize their websites. By offering easy-to-understand, step-by-step guidance, Web Squadron provides practical and valuable content.
Visit
Insert the Blog Post Read Time in WordPress with Code Snippets
Welcome back!
Enter your Helwp credentials to sign in.

No Account yet? Sign Up

My Account
Menu
Give Feedback
Describe your feedback *
Rate Helwp
Share
Facebook
Twitter
LinkedIn
Reddit
Email
WhatsApp
Telegram
Pocket
Report
Problem *
Describe the problem
Want us to reply?
Your E-Mail
Affiliate Disclosure

At Helwp, we’re committed to transparency and honesty. Therefore, we want to inform you that some of the links on our website are affiliate links. This means that, at no additional cost to you, we may earn a small commission if you click through and make a purchase.

We only promote products or services that we genuinely believe in. These affiliate commissions help us to maintain the website and continue to provide you with free, high-quality WordPress content.

If you are interested in how you can support us even further, check out our support page.