Site logo

Archived topic

Conflict between hiding posted date and showing text before updated date

3 replies · Started by Eber on March 7, 2022

Viewing posts 1–4 of 4

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!

Forgive me, the published date was showing because of Rank Math's schema.

Glad to hear :)

This archived topic is closed to new replies.