0%

How To Show Last Updated/Modified date In Blog Post WordPress

When managing a WordPress blog, keeping your content fresh and up-to-date is crucial for both SEO and user engagement. One effective way to inform your readers (and search engines) that your content has been updated is by displaying the last updated or modified date on your blog posts. In this guide, I’ll walk you through why it’s important and how you can easily implement this in WordPress.

📌Why Display the Last Updated Date?

  • SEO Benefits: Search engines like Google favor fresh content. By showing the last updated date, you’re signaling to search engines that your content is current, which can lead to better rankings.
  • User Trust: Readers are more likely to trust and engage with content that appears up-to-date. Displaying the last modified date assures them that the information is still relevant.
  • Transparency: It adds a layer of transparency, showing your audience that you actively maintain and update your content to keep it accurate.

⚙️How to Display the Last Updated Date in WordPress

✏️Method 1: Adding Custom Code

For those comfortable with coding or looking for a more customizable approach, adding custom code to your theme is another option.

  • Access Theme Files: Log in to your WordPress dashboard and navigate to Appearance > Theme File Editor. Open the functions.phpfile of your active theme.
  • Add the Following Code:

🚀Php Codes for Showing Updated or modified date in Post

// Function to display last updated date for post
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time>';

    if ( get_the_date() !== get_the_modified_date() ) {
        $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$s</time>';
    }

    $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() ),
        esc_attr( get_the_modified_date( 'c' ) ),
        esc_html( get_the_modified_date() )
    );

    return sprintf( '<span class="posted-on">%s</span> ',
        $time_string
    );
}, 10, 2 );
  • Save Changes: After adding the code, save the functions.php file. This code will automatically display the last updated date on all single blog posts.
Tutorial Video

✏️Method 2: Using a WordPress Plugin

For those who prefer not to touch code, using a plugin is the easiest way to display the last updated date.

  1. Install and Activate a Plugin: Go to your WordPress dashboard, navigate to Plugins > Add New, and search for a plugin like WP Last Modified Info. Install and activate the plugin.
  2. Configure the Plugin Settings: Once activated, go to the plugin settings. You can usually choose whether to display the last modified date before or after the content, customize the text, and decide if it should appear on posts, pages, or both.
  3. Save Changes: After configuring the settings, save your changes. The last updated date will now be visible on your blog posts.

✏️Method 3: Modifying Theme Templates

  • Edit the Single Post Template: In the Theme File Editor, locate your theme’s single.php or content-single.php file.
  • Add the Code Where You Want the Date to Appear:

🚀Php Codes

<?php if ( get_the_date() !== get_the_modified_date() ) : ?>
    <p class="last-updated">Last Updated on: <?php echo get_the_modified_date(); ?></p>
<?php else : ?>
    <p class="published-on">Published on: <?php echo get_the_date(); ?></p>
<?php endif; ?>
  • Save Changes: Save the file, and the last updated date will appear in your chosen location on single blog posts.

🎯Best Practices for Displaying Last Updated Dates

  • Use Schema Markup: To make your last updated date even more SEO-friendly, consider adding schema markup. This helps search engines understand the structure of your content better.
  • Display Both Dates: If you want to keep both the published and updated dates visible, make sure to differentiate them clearly to avoid confusing your readers.
  • Styling: Use CSS to style the date display, making it prominent but not distracting. A well-designed date format can enhance the readability and professionalism of your blog.

✅Conclusion

Displaying the last updated date on your WordPress blog posts is a simple but effective way to boost SEO, improve transparency, and enhance user trust. Whether you choose to use a plugin, add custom code, or modify your theme templates, keeping your content fresh and up-to-date will benefit both your readers and your search engine rankings.

Start implementing these changes today to keep your WordPress blog ahead of the curve!

Expert WordPress developer specializing in creating engaging, SEO-friendly, and responsive blogging websites.

Share this content:

Leave a Comment