Archived topic
Showing "last updated on" date certain times, and "posted on" date at others.
9 replies · Started by Jay on July 8, 2018
I have a site running Genesis that I'm switching to GeneratePress. There's some stuff in my old child theme's functions.php that I'm trying to bring over to GP using the Code Snippets plugin.
One thing I previously had was some code to show the "last updated" date on single post pages, but show the "posted on" date on other types of pages. This code made that happen...
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter($post_info) {
if ( is_singular( 'post' ) )
$post_info = 'Last Updated on [post_modified_date]';
if ( is_archive( ) )
$post_info = 'Posted on [post_date]';
if ( is_home( ) )
$post_info = 'Posted on [post_date]';
if ( is_search( ) )
$post_info = 'Posted on [post_date]';
return $post_info;
}
How do I adapt this to GP? I already changed genesis_post_info to generate_post_date_output which seems to be correct, but now instead of the dates I just have the actual text of "[post_modified_date]" or "[post_date]" displaying.
Any ideas?
Thanks.
Hi there,
Would this help?
https://docs.generatepress.com/article/show-the-updated-post-date/
You just have to adjust the CSS a bit to target certain pages
Let me know :)
Thanks for the fast reply! This method definitely seems easier, but is there any difference to the end result? Specifically, the method I’ve been using (as seen in my first post) has allowed Google to display the last modified date in their search results as the date shown along with each of my posts.
Would this css method do the same?
Absolutely - Google will pick up the updated date no matter what.
We can even adjust the CSS to only show the updated date on single posts if that works better for you?
Thanks Tom! Yes, I'm trying to only show the last updated date on single posts, and then the original date it was first posted on all archive/search/category pages.
Try this:
.single .posted-on .updated {
display: inline-block;
}
.single .posted-on .updated + .entry-date {
display: none;
}
Thanks! That worked perfectly. The only other thing I need to do here is have the dates not be links... just plain text instead.
Can you give this a shot?
https://generatepress.com/forums/topic/disabling-linking-to-authors-posts/page/2/#post-370185
Thanks!
No problem :)