How to properly show last updated date in For SEO?

Hi, guys, I have been spending many hours updating old stuff.

I updated a few of my blogpost from 2018 > 2020.

Not just date but I also tried to make it evergreen. For example, my old post was 500 words long but I reformat the content length is now more 1800+ words.

But after editing the content I just change the date and make updates.

But here’s the game - In SERP the date will be changed, and it is good at a point of visitors.

But What what about SEO and search bot?

I mean when I checked the structure data. The last modified and updated dates are the same. (I know it need to add code, I added below code bust still not working)

But when I check the structure date of another blog both dates are different.
Check below example of Moz

And do you know the funniest part, these sites do not care about SERP but they focus on structure date in order google can understand both dates.

Somewhere I learned content age is also matters. So I think by reading dateModified and datePublished Google understands, how content is old?

So for this requirement, I googled and found the following code to generatepress theme. Unfortunately, it not working for me.

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> ',
    }, 10, 2 );

Please, Guys, give me solution and also do research and implement yourself, Not sure but maybe it a ranking factor.


If you are using GeneratePress Theme then the above code should work for any updated posts to show last update date. The same code is working at my end.

Can you elaborate what you did with the code?
Where you paste the code?

Will further assist with the code.


1 Like

Can you share a screenshot of the google structure data of any of your updated post?
Like this

I didn’t do anything with code. I just copied and pasted in the child themes function.php file.

1 Like

Ok the code is working for me. Thanks

1 Like

Great to here.

1 Like

Hai @Whois_Games @GulshanKumar I am using generate press premium theme for my blog , I am learning to play with wordpress you guys are helping me a lot.

So I can add this code to my snippets plugin in between php code and I have to enable which one out of this 4 options

Run snippet everywhere
Only run in administration area
Only run on site front-end
Only run once

I want to know this code will change the last modified date in single posts,category and home page also right increasing the seo effect of my posts. Please help me out . Thank you for your time.

You can play with the hook. Go to Appearance > Elements and Add Hook, Under Display Rules, you can choose various options like Entire Site, All Posts, or on a specific post, pages, etc.
Don’t forget to enable Elements in GeneratePress Settings