Show “Last Updated” Date in WordPress for Better SEO & E-E-A-T

In this tutorial, we’ll add an automatic “Last Updated” date to WordPress posts. This helps readers and Google understand that your content is actively maintained, boosting both trust and SEO freshness signals
Author:
|
CTO of
Quanta Digital Agency
Published
If you'd like someone to take care of your marketing, I'm here to help, Click Here

WordPress already stores two key timestamps for every post:

  • post_date → when the post was first published

  • post_modified → when it was last edited

So instead of creating a new custom field, we can simply compare these values and display the “Last Updated” date only when the post has been modified after publishing.

PHP Code for functions.php

Add the following snippet to your theme’s functions.php file:

/**
 * Display "Last Updated" date automatically in posts
 */
function show_last_updated_date() {
    if (is_singular('post')) {
        global $post;
        $modified_time  = get_the_modified_time('U');
        $published_time = get_the_time('U');

        // Show only if the post has been updated
        if ($modified_time > $published_time) {
            $modified_date = get_the_modified_time(get_option('date_format'));
            echo '<p class="last-updated">🕓 Last updated: ' . esc_html($modified_date) . '</p>';
        }
    }
}

add_action('the_content', function($content) {
    if (is_singular('post')) {
        ob_start();
        show_last_updated_date();
        $last_updated = ob_get_clean();
        return $last_updated . $content;
    }
    return $content;
});

💡 You can replace “Last updated:” with any custom text, such as your preferred language or label style.

 

Optional Styling

To make it look clean and minimal, add this CSS in Appearance → Customize → Additional CSS:

.last-updated {
    font-size: 14px;
    color: #777;
    margin-bottom: 12px;
    font-style: italic;
}

You can target the .last-updated class in your CSS to fully customize its style and match your site’s design system.

 

  • Automatically adds a “Last Updated” line above the post content
  • Works only for posts that were edited after publication
  • Uses your site’s default date format (Settings → General → Date Format)
  • No plugin required — lightweight and fully native

Leave a Reply

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

Practical Web Tutorials for WordPress Designers, Developers & SEO Experts on My YouTube Channel
Do you want
 more traffic from Google?

About Peyman Farahani

Peyman Farahani is CTO of Quanta Digital Agency

As a digital problem-solver with a focus on SEO, WordPress, and performance-first design, I’ve helped clients achieve real digital results.

I connect creativity with execution — exploring market gaps, shaping clear ideas, and building solutions that actually make an impact.