[Resolved] Last updated date on Google Search

Home Forums Support [Resolved] Last updated date on Google Search

Home Forums Support Last updated date on Google Search

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #887361
    Mohammad

    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,

    #888065
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Ultimately it’s up to Google whether to display it or not.

    However, some users have reported success by removing the published date from the HTML completely if an updated date exists: https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date

    #888689
    Mohammad

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

    #888905
    Tom
    Lead Developer
    Lead Developer

    Awesome – glad I could help 🙂

    #897511
    Sumit

    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…

    #897766
    David
    Staff
    Customer Support

    Hi there,

    yes that code will output the updated date if one exists if not it will return the published date. The code is PHP, this article covers the methods of adding:

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

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