Site logo

Archived topic

Not showing Last Update Date in google search page

5 replies · Started by John on October 4, 2019

Viewing posts 1–6 of 6

Hello

I am using Last update date for my posts. It works well in my site.

but in google search page still showing publish date.

Please help me to show the update date in search result.

Thanks

Applied below codes. But still showing published date in google structured data testing tool.

Could you check, please?

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">Last Updated: %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 );

How are you adding the code?

Hi there,

the snippet worked and the date that GP outputs is now only displaying the Updated Date.

Google may be picking up the dates from the head meta tags your SEO plugin is adding. Or it may just be its algorithms dictate the published date as more relevant. Generally, given time and re-crawls, it will pick up the date that is displayed on the page. But we can't control that.

This archived topic is closed to new replies.