- This topic has 9 replies, 2 voices, and was last updated 5 years ago by Tom.
-
AuthorPosts
-
March 29, 2019 at 8:11 pm #853908Willya
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..
March 29, 2019 at 11:18 pm #853975WillyaSame 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?
March 30, 2019 at 8:45 am #854390TomLead DeveloperLead DeveloperThat 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.
March 30, 2019 at 10:06 pm #854724WillyaThank you, Tom. This is works!
March 30, 2019 at 11:36 pm #854743WillyaHi 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 π
March 31, 2019 at 6:36 am #854897TomLead DeveloperLead DeveloperI just edited the code to remove the avatar π
April 1, 2019 at 7:32 pm #856404WillyaHi 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.
April 2, 2019 at 8:01 am #857047TomLead DeveloperLead DeveloperHere 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 ); }
April 2, 2019 at 6:35 pm #857487WillyaThank you Tom! Glad to be part of GP family. The support here is awesome!
April 3, 2019 at 8:40 am #858480TomLead DeveloperLead DeveloperYou’re welcome! We’re happy to have you π
Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.