How to Show Last Updated Date in WordPress Posts Using functions.php

If you’re a WordPress website owner, you know how important it is to keep your content fresh and relevant. Google and other search engines prioritize updated content, and users also prefer reading articles that display the latest information.

By default, WordPress only shows the published date of a post, but what if you frequently update your content? Wouldn’t it be great if your visitors saw the Last Updated Date instead of just the original publish date?

In this guide, I’ll show you how to modify the functions.php file to display the last modified date instead of the published date. This will improve SEO rankings, increase user trust, and boost engagement on your site.

Why Should You Display the Last Updated Date?

Before we dive into the tutorial, let’s understand why showing the last updated date is beneficial for your WordPress site.

1. Improves SEO Rankings

Search engines prefer fresh and recently updated content. When you update an article, Google considers it more relevant than outdated posts. This increases the chances of ranking higher in search results.

2. Builds Trust With Readers

If a visitor lands on your blog post and sees an old published date, they might assume the content is outdated and leave. However, if they see a “Last Updated” date, they’ll know the post is still relevant.

3. Increases Click-Through Rate (CTR)

When people search for information on Google, they often choose articles that appear more recent. If your content shows a “Last Updated” date, users are more likely to click on it compared to an article with an older publish date.

4. Keeps Evergreen Content Relevant

Many blog posts are evergreen, meaning they remain useful for years. But as technology, trends, and information evolve, small updates are necessary. By displaying the last modified date, you ensure visitors know your content is up-to-date.

How to Add the Last Updated Date in WordPress (Step-by-Step Guide)

Show Last Updated Date in WordPress Posts
Show Last Updated Date in WordPress Posts

Step 1: Open the Theme Editor in WordPress

To add the last updated date to your posts, follow these steps:

  • Log in to your WordPress Admin Dashboard.
  • Navigate to Appearance > Theme File Editor.
  • On the right side, look for the file named functions.php and click on it.

🚨 Important: Before making any changes, create a backup of your theme. Editing the functions.php file incorrectly can break your site.

Step 2: Add Code to functions.php to Display Last Updated Date

Once you’ve opened the functions.php file, scroll to the bottom and paste the following code:

phpCopyEditadd_filter( 'generate_post_date_output', function( $output, $time_string ) {
if ( is_single() ) { // Ensure it's only applied to single posts
$time_string = 'Published on: %2$s';

if ( get_the_date() !== get_the_modified_date() ) {
$time_string = 'Last Updated on: %4$s';
}

$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( '%s ',
$time_string
);
}

return $output; // Return the original output on other pages
}, 10, 2 );

Step 3: Save Changes and Check If It Works

After pasting the code, follow these steps:

  • Click the Update File button to save the changes.
  • Open one of your blog posts and check if the last updated date appears correctly.
  • If you don’t see any change, clear your browser cache or use a different browser.

Alternative Method: Display Last Updated Date Without Editing functions.php

If you’re uncomfortable editing theme files, you can also use a WordPress plugin to show the last modified date.

Best WordPress Plugins to Show Last Updated Date

🔹 WP Last Modified Info – Allows you to display the modified date in posts, pages, and RSS feeds.
🔹 WP Meta and Date Remover – Gives control over how and where the published and updated dates are displayed.
🔹 Code Snippets – Lets you add PHP code snippets without modifying theme files.

To use these plugins, follow these steps:

1️⃣ Go to Plugins > Add New in WordPress.
2️⃣ Search for the plugin (e.g., WP Last Modified Info).
3️⃣ Click Install and then Activate the plugin.
4️⃣ Adjust the settings to display the last updated date.

This method is easier for beginners and prevents theme file modifications.

How to Style the Last Updated Date Using CSS

If you want to make the “Last Updated” text stand out, you can add some CSS styling:

1️⃣ Open Appearance > Customize > Additional CSS.
2️⃣ Paste the following CSS code:

cssCopyEdit.last-updated {
font-weight: bold;
color: #ff6600;
font-size: 14px;
display: block;
margin-top: 10px;
}

3️⃣ Click Publish to save the changes.

This will make the last updated date appear in bold orange color, making it more visible.

Common Issues and Troubleshooting

Issue 1: The last updated date is not appearing
✔️ Solution: Clear your website cache and browser cache. Try viewing the post in an incognito window.

Issue 2: The last updated date is incorrect
✔️ Solution: Make sure you have actually modified the post. WordPress only updates the modified date when you edit and save changes.

Issue 3: Changes disappear after a theme update
✔️ Solution: If your theme updates frequently, consider using a child theme or a plugin like Code Snippets to preserve your changes.

Final Thoughts: Why This Change Matters

Adding the last updated date in WordPress is a small but powerful tweak that can significantly impact SEO, user trust, and engagement.

Here’s a quick summary of the benefits:

🔹 Boosts SEO rankings by showing Google that your content is fresh.
🔹 Increases credibility by informing users about recent updates.
🔹 Improves click-through rates (CTR) by making your post look more recent.
🔹 Ensures evergreen content stays relevant with minor updates.

If you want your WordPress site to perform better in search results, displaying the last updated date is a must-have feature.

What’s Next?

✅ Try implementing the functions.php method or use a plugin if you’re not comfortable with code.
✅ Clear your cache and check if the updated date is displaying properly.
✅ Experiment with CSS to style the date for better visibility.

I hope this guide helped! If you have any questions, feel free to comment below. 🚀

Author Image
Dipak Badaila

Hi, I'm Dipak, the admin and content creator of Earn Bit Win. I love sharing tips on blogging, social media, earning money, crypto, and the stock market to help you grow and succeed.

Learn More

Leave a Comment