Archived topic
date snippet in home page
1 reply · Started by Pere on November 14, 2018
Viewing posts 1–2 of 2
Hello, I would like to remove the date snippet on my home page on google.
But I want to keep enabled last updated date on posts
pd: i have yoast

Hi there,
We can try removing the microdata, but I don't think Google cares. If the date is visible on the page, they'll show it within the search results.
To remove the microdata, you can do this:
add_filter( 'generate_post_date_output', function() {
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="updated" datetime="%3$s">%4$s</time>' . $time_string;
}
$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">%1$s</span>', // WPCS: XSS ok, sanitization ok.
sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
)
);
} );
This archived topic is closed to new replies.