- This topic has 25 replies, 7 voices, and was last updated 3 years, 8 months ago by
Ying.
-
AuthorPosts
-
October 1, 2020 at 4:06 am #1466881
Stevie
Hi guys
Using the snippet below, my posts update to date of the post revision.
However I’d still like to keep the original post date in there.
is there a workaround?generate post date output:
add_filter( ‘generate_post_date_output’, function( $output, $time_string ) {
$time_string = ‘<time class=”entry-date published” datetime=”%1$s” itemprop=”datePublished”>%2$s</time>’;if ( get_the_time( ‘U’ ) !== get_the_modified_time( ‘U’ ) ) {
$time_string = ‘<time class=”entry-date updated-date” datetime=”%3$s” itemprop=”dateModified”>%4$s</time>’;
}$time_string = sprintf( $time_string,
esc_attr( get_the_date( ‘c’ ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( ‘c’ ) ),
esc_html( get_the_modified_date() )
);return sprintf( ‘<span class=”posted-on”>%s</span> ‘,
$time_string
);
}, 10, 2 );October 1, 2020 at 5:22 am #1466990David
StaffCustomer SupportHi there,
you don’t need that snippet – GP will automatically output both dates if they exist – it just hides the update date. You can change that with this CSS:
/* Display updated date */ .posted-on .updated { display: inline-block; margin-right: 1em; } /*Add date prefixes */ .posted-on .updated:before { content: 'Updated: '; } .posted-on .entry-date:before { content: 'Published: '; }
October 1, 2020 at 7:46 am #1467256Stevie
thanks David, I’ll give that a try on a test site first
October 1, 2020 at 8:38 am #1467530David
StaffCustomer SupportYou’re welcome
October 1, 2020 at 10:18 am #1467723Stevie
Hi David.
With snippet deactivated and this css added, it appears to only show both dates on category pages.
Not on blog page or single post pages.
Ideally when I update a post, I’d like the ‘updated’ date to appear on Google search too.
Click through from Google and see the date of update, with the original published date below.
God,Sorry I’m really pestering you today !
Here’s the test site I’m trying these out on:October 1, 2020 at 1:08 pm #1467993Stevie
sorry David, that may have been a caching delay – it’s showing up on post pages now.
Two more questions and that’s it – promise!
1.Do both these dates show up in serps?
2.I note the post dates are also hyperlinks to the post. Is that normal in WordPress?
I’m still using the generate post date snippets code on my main site, and it’s just plain text, not hyperlinked to the post.October 1, 2020 at 7:52 pm #1468327Tom
Lead DeveloperLead DeveloperHi there,
1. No, I believe Google will only display one (usually the published date when both are active).
2. It’s linked by default now, but that link was removed in 3.0: https://generatepress.com/generatepress-3-0-a-new-era/
October 2, 2020 at 10:09 am #1469490Stevie
Thanks Tom.
With the GP ‘generate post date snippets’ code active on my main site, Google shows only the new date which is my intention for the serps.
But ideally when a visitor clicks through, I want them to see the original post date as well.
Obviously the url still shows original date, but only on desktops.
It seems a pity that WP just doesn’t have it built in to its code. It seems logical to inform the visitor correctly.In meantime:
From my test site, I’ve removed the snippets code,and added David’s suggested css. At present it shows both dates on the site as he said it would.
I’ll wait and see what Google search displays in coming week or so.October 2, 2020 at 1:20 pm #1469725Tom
Lead DeveloperLead DeveloperI’m not sure how Google determines which date to show. However, I’ve noticed that if both dates are visible, they will show the published date for some reason. It’s only when the published date is removed that they display the updated date.
October 2, 2020 at 1:48 pm #1469749Stevie
c’est la Google !
I still haven’t figured out, after reading enough seo experts opinions to make my head bleed, which
of the options is the better.
One argument being that a human visitor is more likely to click through if it says ‘2020’ , as apparently my wise and weighty tomes ( on vintage fashion in my case) aren’t click bait if they are more than a year old.Mine go wayyy back to the ancient days of 2009. Some of the world’s libraries go back even further apparently!
If I could add that GP ‘generate post date output snippet’ just for specific posts then I would have the best of both worlds.
Thanks anyway Tom !October 3, 2020 at 10:52 am #1470822Tom
Lead DeveloperLead DeveloperWe’re exploring a Blog Element that will allow for blog settings to be applied conditionally using Display Rules – should happen soon 🙂
October 4, 2020 at 5:08 am #1471426Stevie
That’s great. Look forward to seeing that option.
Thanks TomJanuary 5, 2021 at 2:07 am #1606111culpable
Heya Tom,
Just tacking on to this – I found your filter here form the article you linked (for those that would like the direct link, it’s here.
Tom I currently have the updated date showing on the front end, but both are present in the schema (I’m intentionally not using the snippet above).
Instead of the above solution – is there a way for me to make the published date = the last updated date?
So the “Published date” schema will still end up showing in the source code, but it will be equal to the “Last Updated” date.
From what I’ve seen analyzing other sites, this seems to be the best way to get Google to recognize that the page has been updated.
Thank you so much for your help! 🙂
January 5, 2021 at 10:38 am #1606967Tom
Lead DeveloperLead DeveloperHi there,
That is basically what this filter does: https://docs.generatepress.com/article/generate_post_date_show_updated_only/
It completely replaces the published date in the HTML with the updated date, so only one date is present in the HTML. There should be no other schema unless it’s being added by a plugin.
January 6, 2021 at 4:33 pm #1608688culpable
Heya Tom,
Thanks for helping me out.
To clarify: I want both schema present, I just want the published date to be equal to the last updated date. See 👉🏻 https://imgur.com/Yw8kxwW 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.