How to Show Last Updated Date in GeneratePress Theme?
-
Hello David,
hope you are fine.I want to show the Last Updated Date in GeneratePress for my blog readers and also for Google.
Because showing the last updated date in Google is a good SEO practice.
But according to GeneratePress, Show the “Updated” Post Date – Documentation. I’m a little confused.You can see the CSS code below.
.posted-on .updated { display: inline-block; } .posted-on .updated + .entry-date { display: none; } .posted-on .updated:before { content: "Last Updated: "; }
Someone told me that if I use the above CSS code. It only shows the last updated date to only blog readers but if I use the below custom function. it shows the last updated date to blog readers and Google too.
add_filter( 'generate_post_date_output', function( $output, $time_string ) { $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time>'; if ( get_the_date() !== get_the_modified_date() ) { $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %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 );
So David, please see the image below, I want to show the last updated date like the below image. So can you please suggest me which method I can use to show the last update date in GeneratePress?
The page I need help with: [log in to see the link]
- The topic ‘How to Show Last Updated Date in GeneratePress Theme?’ is closed to new replies.