Site logo

Archived topic

Last updated date on Google Search

5 replies · Started by Mohammad on May 2, 2019

Viewing posts 1–6 of 6

Hello,

Although on my blog it shows last updated date, on Google search page it shows the publish date. How I can show the last updated date on Google search page.

Here is my blog url.

https://pmstudycircle.com/blog/

Regards,

Thanks Tom your code worked. Now Google is showing last update date.

Awesome - glad I could help :)

Hi tom, do you want to say that if I'll add this code only then Last updated date will show in the Google search result.

add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';

    if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
        $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%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 );

If yes,

then Please tell me where to add this code and how to add this code?

Waiting for your reply...

This archived topic is closed to new replies.