Archived topic
Show last update date on posts and google results
23 replies · Started by Fekry on April 26, 2020
Hi there
I've put this below filter in Snippet plugin to (Show last update date on posts and google results), but updated word shows in every post I publish, not only in the updated ones as I wish.
May you show me what I should do ?
Thanks
................................
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">updated: %s</span> ',
$time_string
);
}, 10, 2 );
Hi there,
Try this CSS:
https://docs.generatepress.com/article/show-the-updated-post-date/
Hi Leo.
that is not working? Word (last updated) shows in the post which I just published and I did not modified it.
May you check the "URL" link please?
Can you disable the coming soon page?
Are we referring to what is displayed or the source?
I disabled the coming soon page. You can have a look now.
leo, I am waiting your help and do not want to disable the coming soon page for long time, my site is not ready yet.
Hi there,
Can you try the updated function here?: https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date
Let me know :)
Hi Tom.
this filter also shows updated word in all posts (updated and just published) and remove the date.
I've put a new URL link in the orginal message for a fake post I just published.
I need word "updated" to show only in the really updated posts.
What should I do?
That code shouldn't actually include any "updated" or "published" words - was going to add those using CSS after.
Can you make sure you're not using any other filters/custom functions?
Ok Tom. It was my fault. Now there is now “updated” word. What should do next (CSS)?
Here you go:
.updated-date:before {
content: "Updated on ";
}
.published:before {
content: "Published on ";
}
I've modified the post, but nothing shows in the meta line! I need to show "updated" word.
Hello Tom..
Hi there,
can you remove the coming soon so we can take a look
Sure. May you check it please.