- This topic has 13 replies, 4 voices, and was last updated 3 years, 4 months ago by
Ying.
-
AuthorPosts
-
September 1, 2021 at 10:32 am #1915655
Andy
Hi,
I have been using this code on a number of articles to show ‘Last updated’ instead of published date:
}
.posted-on .updated:before {
content: “Last updated: “;
}
.posted-on .updated {
display: inline-block;
}
.posted-on .published {
display: none;
}However, I now realise that this doesn’t affect what is shown in Google and it’s important for these articles to appear current in the SERPS.
How do I change it so the ‘Last updated’ date appears in Google instead of the published date?Thank you,
September 1, 2021 at 10:42 am #1915664Ying
StaffCustomer SupportHi Andy,
You can try this PHP snippet:
https://docs.generatepress.com/article/generate_post_date_show_updated_only/Adding PHP: https://docs.generatepress.com/article/adding-php/
Hope it’s helpful 🙂
September 1, 2021 at 10:52 am #1915681Andy
Hi,
Am I right in assuming the code you attached will do what is already being done? i.e. hide the ‘published’ date and only show ‘Last updated’?For example, in the url attached, it already shows last updated using the css i attached. But Google only shows the date published. In Source, I can see both dates?
Thank you,
September 1, 2021 at 10:57 am #1915687Ying
StaffCustomer SupportThe PHP snippet is NOT doing hiding, but doing removing, which is different from what CSS does.
With the PHP snippet, if there’s an updated date, then the published date won’t show up in HTML.
Hope I made it clear.
September 1, 2021 at 11:05 am #1915702Andy
Hi,
Yes, that makes it more clear. This PHP code you sent will remove the published date so only the last updated shows up.
If I add this PHP using the code snippets plug in, should I then remove the CSS code i originally pasted from all the articles?
Thank you,September 1, 2021 at 11:29 am #1915731Ying
StaffCustomer SupportYou can remove the CSS and you won’t need the CSS for the hiding published date purpose.
But if you want to add prefix: “last updated:” before the updated date, we can have a look later and provide another set of CSS.
Let me know 🙂
September 1, 2021 at 1:17 pm #1915872Andy
Hi,
thanks for your reply.
Yes, i’d like to add “last updated”…
How shall i go about this?
Thanks,September 1, 2021 at 1:49 pm #1915907Ying
StaffCustomer SupportGive this CSS a try:
.inside-article .posted-on .updated-date:before{ content: "Last Updated: "; }If it doesn’t work, you can link us to the site after you implanted the PHP snippet and clear cache 🙂
September 2, 2021 at 1:40 am #1916249Andy
What will happen to articles which have never been updated? Will their published date still show? Or is that now hidden too?
ThanksSeptember 2, 2021 at 6:41 am #1916488David
StaffCustomer SupportHi there,
articles that have never been updated will display the published date.
September 6, 2021 at 3:26 am #1920221Andy
Hi, thank you for your quick responses.
I have added the snippet and the css and all works perfectly (thank you very much),
But, can I just triple check one last thing: I checked the url on https://validator.schema.org/ and under CreativeWork I noticed the published date has been removed and it only shows date modified. Will this not cause confusion for Google?
Thank you,September 6, 2021 at 4:21 am #1920286David
StaffCustomer SupportThats correct the Snippet removes any HTML/Meta for the second date.
I can’t say how google decides on what date to display, they like to keep the algorithms a mystery.
But the best results are seen when there is a single date in the schema and that same date is displayed on the frontend. It removes any option for Google to choose the wrong date from the site. But it doesn’t meant that google will.For best results to get your dates in the SERPs is to use a JSON-LD plugin or SEO plugin that does that for you, that will ensure Google gets the exact info its looking for.
November 29, 2022 at 10:12 am #2441554John
Hi Ying, I followed this tips but I’d like to add some text before the date ” Last Updated On”
I tried this
.inside-article .posted-on .updated-date:before{
content: “Last Updated: “;
}but it doesnt work for me. was hopping you could help
November 29, 2022 at 3:10 pm #2441924Ying
StaffCustomer SupportHi John,
Can you open a new topic and link us to an article that’s been updated?
Let me know 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.