Archived topic
Date not updating in Google
22 replies · Started by Tibs on May 28, 2020
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 );
Ok, so here are how my current snippets look like:
Only Show Updated Date: http://prntscr.com/sqvali
Author/Date: http://prntscr.com/sqvase
Custom CSS: http://prntscr.com/sqvayi
Did I get that right?
If so, any way I can add a separator between author and date: http://prntscr.com/sqvba2?
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!