-
Hi!
I want my posts to show the original post date and not the last updated date. here’s a link to a previous topic I created, which shows all my posts with the updated date — https://generatepress.com/forums/topic/adding-post-date-to-posts/#post-2467494
Thanks!
-
Fernando
Hi Sean,
For reference, can you share the link to the site in question?
-
-
Hi there,
go to Customizer > Additional CSS and DELETE this:
.posted-on .updated { display: inline-block; } .posted-on .updated+.entry-date { display: none; } .posted-on .updated:before { content: "Last Updated "; }
-
Wonderful! Thank you for that. A related question: I’d like to add the author next to the date in the posts. I’ve checked the box in customizer/layout/blog for both archives and single, but I’m not seeing the author listed at the top (although I see it in my blog archive). Thanks!
-
In the Blog settings theres a separate Tabs for Archives and Single.
Check the Single one for the setting:https://docs.generatepress.com/article/blog-content-layout/#single
-
Thanks, but I’ve done that and it isn’t working. It might be related to this snippet I’ve added to make the tags/categories go to the top:
add_filter( 'generate_header_entry_meta_items', function($item) { if (is_single()) { return array( 'date', 'categories', 'tags' ); } return $item; } );
-
Yeh, thats overriding the customiser. You can add
author
to it:add_filter( 'generate_header_entry_meta_items', function($item) { if (is_single()) { return array( 'date', 'author', 'categories', 'tags' ); } return $item; } );
-
Oh you’re amazing! Thank you. One last question I think! Is it possible to also include an updated date next to the original date?
Like:
April 12, 2023 (last updated: April 20, 2023) by Author
-
Try adding this PHP Snippet as well as your current one:
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_date() !== get_the_modified_date() ) { $time_string = ' <time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time> <time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">( Last Updated: %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 );
-
You are a magician!! Thank you so much 🙂
-
Glad to be of help!
- You must be logged in to reply to this topic.