- This topic has 7 replies, 3 voices, and was last updated 4 months, 2 weeks ago by
Tom.
-
AuthorPosts
-
October 12, 2020 at 5:06 pm #1485766
Connor R
Hi there,
I use a code snippet (I believe it’s the one below) to show the post updated date in my post meta data.
Following the latest update of GP, some of my posts are now missing the date (even if I have hit the update button in the WP backend).
Any help resolving this bug would be greatly appreciated. Thank you!
add_filter( 'wpsp_date_output', 'tu_wpsp_updated_date_first' ); function tu_wpsp_updated_date_first() { $time_string = ''; $time_string .= '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$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() ) ); // If our date is enabled, show it $output = sprintf( '<span class="wp-show-posts-posted-on wp-show-posts-meta"> %1$s </span>', $time_string ); return $output; }
October 12, 2020 at 5:24 pm #1485783Elvin
StaffCustomer SupportHi,
Can you link us to the site in question so we could take a closer look?
You can add the site details on the Private Information text area. Thank you.
A wise man once said:
"Have you cleared your cache?"October 12, 2020 at 5:27 pm #1485787Connor R
Hi Elvin,
I have put the site in question in the private info area. I have tried clearing the cache as well.
October 12, 2020 at 7:37 pm #1485878Tom
Lead DeveloperLead DeveloperHi there,
The code you shared is for WP Show Posts – it doesn’t have any effect on GeneratePress.
Are you using a different function for GP, maybe?
Let us know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 12, 2020 at 7:59 pm #1485890Connor R
Anddddd this is why I know when I’m in over my head and head for the forum :)!
I believe my post meta data snippet is below:
add_filter( 'generate_footer_entry_meta_items', function() { return array( ); } ); add_filter( 'generate_post_author_output', function() { return sprintf( ' <span class="byline">%1$s</span>', sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-label">Written by </span><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span><br>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ), esc_html( get_the_author() ) ) ); } ); add_filter( 'generate_inside_post_meta_item_output', function( $output, $item ) { if ( 'categories' === $item ) { return ' | '; } return $output; }, 50, 2 ); add_filter( 'generate_header_entry_meta_items', function() { return array( 'author', 'date', 'categories', ); } );
I believe showing the updated date (rather than the published date) is done in the CSS using the below:
.posted-on .updated { display: inline-block; } .posted-on .published { display: none; }
Like I said, for some reason this used to work, but after updating GP/GP Premium, it only works on some posts.
Thanks for the help!
October 13, 2020 at 9:40 am #1487064Tom
Lead DeveloperLead DeveloperInstead of this:
.posted-on .published { display: none; }
Do this:
.posted-on .updated + .published { display: none; }
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 13, 2020 at 12:52 pm #1487403Connor R
That did the trick. Thank you, Tom!
October 14, 2020 at 9:42 am #1488907Tom
Lead DeveloperLead DeveloperYou’re welcome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.