[Resolved] Date in Google SERPs not updating

Home Forums Support Date in Google SERPs not updating

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1312189
    Xin Yi

    Hi guys,

    Been on generatepress for a few years now. Great theme and support! It’s my first posting on the support forum because I do need some help with this specific issue.

    My main concern is that the last updated date not updating in google searches. It’s important to me.

    A bulk of my posts are supposed to reflect the latest information in the year 2020. But it’s still showing the published date (which is 2019). This is even after major updates with the content (eliminating 50%, total restructure, etc). And it has been months but it still isn’t updated. Which seems a little odd.

    Observations
    – I used codes gathered from generatepress
    – the last updated date on SERPs hasn’t change once even after constant updates. Only published date is shown
    – on the article page, it shows exactly how I want it to be (visually), but the “last updated” words doesn’t seem to be regular text (not sure whether it’s an issue).

    I understand that this might not be under the scope but I’ve no clue how to rectify this, so would greatly appreciate if someone can check out whether the codes are alright. Thanks!

    #1312898
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This is something we’ll be addressing directly in the theme. While they don’t directly say it, it seems Google will only show the updated date if the updated date is the only date in the HTML source of the page.

    For now, try this function: https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date

    #1313076
    Xin Yi

    Thanks, Tom!

    It seems to be working. At least the old date is taken out from the SERPs.

    How do I add the text: “Update” before the date though?

    Current CSS I’m using:

    .entry-header, .entry-meta {
        text-align: center;
    }
    
    .byline img {
        width: 25px;
        height: 25px;
        border-radius: 50%;
        position: relative;
        vertical-align: middle;
        margin: 0 10px 0 0;
    }
    
    .comments-link,
    .posted-on {
    	border-left: 1px solid #ddd;
    	padding-left: 10px;
    	margin-left: 10px;
    }

    Current Function:

    
    add_filter( 'generate_post_author_output', function() {
        return sprintf( ' <span class="byline">%1$s</span>',
            sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%2$s<span class="author-name" itemprop="name">%1$s</span></span>',
                esc_html( get_the_author() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );
    
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'comments-link',
            'date',
        );
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array(
            'categories',
        );
    } );
    
    //   remove publisheddate
    
    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>';
    
        $updated_time = get_the_modified_time( 'U' );
        $published_time = get_the_time( 'U' ) + 86400;
    
        if ( $updated_time > $published_time ) {
            $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 );
    #1313316
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You can replace this line:

    $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';

    With this:

    $time_string = 'Updated: <time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">%4$s</time>';

    #1313476
    Xin Yi

    Thanks Tom!

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