Archived topic
The Last Update Date on Some Post Does not Show on Google Search
9 replies · Started by Willya on March 29, 2019
Hi,
So, I use the code that David created for me on this post to show entry meta with gravatar, last update and comment.
The last update show correct on all of my post.
But, the problem is on some of my post, the last udpate date is does not show on Google search, while the others post is show last update correctly on Google search.
I include for example my post url on the form, so that Admin can check it.
I just cant relax because of this problem.
I have try Clear the cache and forced Google to fetch it on Google Search Console.
But it seems not work
I think I need to remove date published from the code. Please help me..
Same problem with this thread: https://generatepress.com/forums/topic/how-to-show-updated-posts-with-plugin/
Is the code Tom created on this post is still works?
That won't work if you're already using the function David gave you.
You could try something like this:
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_show_comments', '__return_false' );
add_filter( 'generate_post_date_output', 'tu_fancy_byline' );
function tu_fancy_byline( $date ) {
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
esc_html( get_the_author() )
)
);
$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="updated" 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() )
);
printf( '<span class="posted-on">%s</span>', // WPCS: XSS ok, sanitization ok.
$time_string
);
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
echo '</span>';
}
}
However, it's up to Google whether to show the date or not for a specific article.
Thank you, Tom. This is works!
Hi Tom, I want to remove avatar photo. So, the entry meta just show: Author name, last updated and comments count.
How to do that in the code above?
Thanks for your super support anyway :)
I just edited the code to remove the avatar :)
Hi Tom. I am sorry I change my mind. Could you edit once again the code above to just show only "author name (with no avatar) and last updated date". So, no comments count on the entry meta.
Here you go:
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_post_date_output', 'tu_fancy_byline' );
function tu_fancy_byline( $date ) {
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
esc_html( get_the_author() )
)
);
$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="updated" 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() )
);
printf( '<span class="posted-on">%s</span>', // WPCS: XSS ok, sanitization ok.
$time_string
);
}
Thank you Tom! Glad to be part of GP family. The support here is awesome!
You're welcome! We're happy to have you :)
Thanks!