Archived topic
Conflict between hiding posted date and showing text before updated date
3 replies · Started by Eber on March 7, 2022
Hello!
I have searched this forum for a way to show only my updated date and hide the posted date.
I added this to the functions.php file:
add_filter( 'generate_post_date_show_updated_only', '__return_true' );
And then added this to the additional CSS area:
.posted-on .updated {
display: inline-block;
}
.posted-on .updated+.entry-date {
display: none;
}
It works very well, showing only the updated date.
But I would like to add "Updated on" before that date. To do that I found this:
.posted-on .updated:before {
content: "Last Updated ";
}
.posted-on .entry-date:before {
content: 'Published';
}
The problem is that it does not work, since the first CSS snippet says display:none.
Then if I remove that, the posted date appears in the source code of the page, even though it is not appearing. And then the problem is that Google picks the posted date to show on the SERPs.
My need is to show "updated on" before the updated date, without showing the posted date on the source code. Can you please tell me how to do so?
Thanks!
Hi there,
Are you using the block editor?
If so I'd highly recommend converting over to use a block element post meta:
https://docs.generatepress.com/article/block-element-post-meta-template/
https://docs.generatepress.com/article/dynamic-data/#post-date
It should solve all issues and avoid the use of any PHP or CSS.
Forgive me, the published date was showing because of Rank Math's schema.
Glad to hear :)