Site logo

Archived topic

Date not updating in Google

22 replies · Started by Tibs on May 28, 2020

Viewing posts 16–23 of 23

Now change your date filter to this:

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 = 'Updated <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 );

Looks good! Try this CSS:

.entry-header .entry-meta > *:not(:last-child):after {
    content: " | ";
}

That worked :)

I'll keep an eye out for the date on Google and will let you know if it worked. Thanks again Tom!

No problem :)

The date updates in Google!

Thanks Tom! You're the man :)

(Just out of curiosity, what plugin would you recommend for Schema Markup? Star rating, review box, product details, etc.)

I don't really have a go-to one. I would suggest going the JSON-LD route vs. HTML. There should be a lot of options out there if you search "WordPress JSON-LD" :)

Will do, thanks!

This archived topic is closed to new replies.