- This topic has 12 replies, 3 voices, and was last updated 7 months, 3 weeks ago by
Leo.
-
AuthorPosts
-
May 28, 2020 at 12:37 pm #1305494
John
I want to display this post last updated date on google. Using this PHP snippet
function display_modified_date_shortcode () { $mod_date = get_the_modified_date(); if ( get_the_date() !== $mod_date ) { return 'Updated On ' . $mod_date; } } add_shortcode( 'modified_date', 'display_modified_date_shortcode' );
And this shortcode in my post hero header.
[modified_date]
I also unchecked “post date” from single post settings from customizer.
Last updated date showing on post.
Is my process okay to show the modified date on google?
Or need to do anything?
Thanks
May 28, 2020 at 2:29 pm #1305616Tom
Lead DeveloperLead DeveloperHi there,
Since you’re using JSON-LD to provide the correct schema, simply displaying the date like that should be just fine.
If you weren’t using JSON-LD, you would likely need to add microdata to the text itself. However, that shouldn’t be necessary in your case π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 28, 2020 at 4:09 pm #1305688John
Hi tom,
I have re-crawled one of my older posts from google search console but still google showing the published date.
May 29, 2020 at 9:02 am #1306611Tom
Lead DeveloperLead DeveloperHave you run your site through a structured data testing tool?: https://search.google.com/structured-data/testing-tool/u/0/
Can Google see the modified date?
Whether they display it or not is up to them. Typically they will display the date that’s in the structured data AND displaying on the page. So if it’s in the structured data and the updated date is the only date on the page, they should pick it up.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 29, 2020 at 9:22 am #1306657John
Checked in structure data testing tool. https://prnt.sc/sq6qey
Both published and modified dates are showing in article schema.
If I got your point, I have to remove the published date and only keep the modified date.
How can I do this?
I’m using “Markup (JSON-LD) structured in schema.org” plugin to display article schema.
May 29, 2020 at 4:07 pm #1307073Tom
Lead DeveloperLead DeveloperFrom what I can see, you only have the updated date visible on the page – is that correct? If so, I think that’s all it *should* take for Google to start using it.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 5, 2020 at 2:29 am #1315198John
Hi Tom,
Waiting few days but Google not showing any date.
Could you please add microdata for this text of code?
function display_modified_date_shortcode () { $mod_date = get_the_modified_date(); if ( get_the_date() !== $mod_date ) { return 'Updated On ' . $mod_date; } } add_shortcode( 'modified_date', 'display_modified_date_shortcode' );
I think It can be helpful
June 5, 2020 at 9:58 am #1315884Tom
Lead DeveloperLead DeveloperTry this:
function display_modified_date_shortcode () { $mod_date = get_the_modified_date(); if ( get_the_date() !== $mod_date ) { return sprintf( 'Updated On <time class="updated" datetime="%1$s" itemprop="dateModified">%2$s</time>', esc_attr( get_the_modified_date( 'c' ) ), esc_html( $mod_date ) ); } } add_shortcode( 'modified_date', 'display_modified_date_shortcode' );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentJune 5, 2020 at 10:19 am #1315911John
Thanks tom,
Applied but no date showing. Might be this CSS cause the issue.
.page-hero time.updated { display: none; }
What should I do?
June 5, 2020 at 12:24 pm #1316049Leo
StaffCustomer SupportCan you try removing that CSS?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/June 5, 2020 at 9:34 pm #1316371John
No, I don’t know where is the CSS file. Is It in style.css?
More so, What happen when you update the core file in future?
June 6, 2020 at 6:18 am #1316716John
Solved my problem. Thanks, both of you!
June 6, 2020 at 8:05 am #1316911Leo
StaffCustomer SupportNo problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.