[Support request] Not showing Last Update Date in google search page

Home Forums Support [Support request] Not showing Last Update Date in google search page

Home Forums Support Not showing Last Update Date in google search page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1026261
    John

    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

    #1026298
    Leo
    Staff
    Customer Support

    Hi there,

    By default both the published date and updated date are in the markup – Google decides what to read.

    You can try only showing the updated date in the markup using this PHP snippet:
    https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1026316
    John

    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 );
    
    #1026327
    Leo
    Staff
    Customer Support

    How are you adding the code?

    #1026335
    John

    By Code Snippets plugin.

    Check this screenshot – https://prnt.sc/pexb46

    #1026547
    David
    Staff
    Customer Support

    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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.