- This topic has 13 replies, 6 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
March 1, 2019 at 4:01 am #825433
Swadhin
Hi Tom,
I am facing a serious issue where Google is not picking up “last updated” date and time and showing published ones. I tried various codes (one Brian from woorkup uses, and ones I was provided within the GP forum).
At last, I need to resort to an external plugin (so that some posts like coupons that are very critical on date for CTR in search) would not lose rankings (they are losing rankings now).
I want to use the plugin “Last Modified Info plugin” as mentioned in this post on authority hacker.
Please tell me how to integrate it on my site (link given in website URL section).
P.S. I have made customizations for including gravatar in post meta section and that’s why I don’t want to hurt its design.
Thank you,
-SwadhinGP Premium 1.7.8March 1, 2019 at 7:53 am #825715Ender
Have you checked this documentation https://docs.generatepress.com/article/show-the-updated-post-date/ ?
Try this code:
https://gist.github.com/generatepress/ba6e3febda3b856b8c3ac29fd5054ce6March 1, 2019 at 9:07 am #825786Tom
Lead DeveloperLead DeveloperThat second link that Ender provided should help.
However, it’s ultimately up to Google whether they show the updated date or not – all we can do is display the necessary HTML/microdata.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 1, 2019 at 9:19 am #825799Swadhin
Hi Tom & Ender, thank you for those snippets.
I think I have added that code.
Can you please show me a way to integrate that plugin to show correctly in the post meta data.
Thanks
Thank you,
-SwadhinMarch 1, 2019 at 3:04 pm #826026Tom
Lead DeveloperLead DeveloperAs far as I can see, that plugin couldn’t be necessary with that code snippet ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 1, 2019 at 9:59 pm #826181Swadhin
Hi Tom,
I used that code and it now shows two lat updated dates. I have included site and URL in the site section.
Let me know if you need login details too.
Thank you,
-SwadhinMarch 2, 2019 at 9:24 am #826659Tom
Lead DeveloperLead DeveloperDo you have another filter added that alters the post meta? If so, can you share it with me?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 2, 2019 at 10:03 am #826692epickenyan
I also got two dates and I have tried the function twice (about two weeks ago and today). I only have the CSS for generatepress added to show last updated date and when I added the function, it showed double last updated dates. Removing the css removed both dates. http://prntscr.com/msbrga
March 2, 2019 at 8:34 pm #826989Swadhin
Yes Tom,
I have this code for showing author gravatar, date and comment link in post meta.
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">%4$s<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() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); if ( ! is_single() && ! 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>'; } echo $date; }
Also, I do have this code to customize the author gravatar
add_filter( 'generate_post_author_output', 'tu_add_author_gravatar' ); function tu_add_author_gravatar() { printf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s %5$s<a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>', __( 'by','generatepress'), 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() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); }
Apart from that, I have the following CSS related to dates:
.posted-on .updated { display: inline-block; } .posted-on .updated + .entry-date { display: none;
Thank you.
Thank you,
-SwadhinMarch 2, 2019 at 10:07 pm #827017Tom
Lead DeveloperLead DeveloperSo this would be your full (and only) function:
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">%4$s<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() ), get_avatar( get_the_author_meta( 'ID' ) ) ) ); if ( ! is_single() && ! 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>'; } $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() ) ); return sprintf( '<span class="posted-on">%s</span>', // WPCS: XSS ok, sanitization ok. $time_string ); }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 2, 2019 at 10:29 pm #827030Swadhin
Thanks Tom,
I applied it and it worked wonders!
Thanks so much again… I am really relieved.
Thank you,
-SwadhinMarch 3, 2019 at 8:27 am #827463Sumit
I want to display gravatar image, name, no. of comments and last modified date below post title.
Please share code and also tell me where to add those codes.
Waiting for your feedback.
March 3, 2019 at 8:37 am #827475David
StaffCustomer SupportSumit – i have answered this on your Topic.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 3, 2019 at 9:19 am #827518Tom
Lead DeveloperLead DeveloperGlad I could help! ๐
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.