Archived topic
Last updated - not showing in Google
13 replies · Started by Andy on September 1, 2021
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,
Hi 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 :)
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,
The 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.
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,
You 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 :)
Hi,
thanks for your reply.
Yes, i'd like to add "last updated"...
How shall i go about this?
Thanks,
Give 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 :)
What will happen to articles which have never been updated? Will their published date still show? Or is that now hidden too?
Thanks
Hi there,
articles that have never been updated will display the published date.
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,
Thats 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.
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
Hi John,
Can you open a new topic and link us to an article that's been updated?
Let me know :)