- This topic has 11 replies, 2 voices, and was last updated 6 years, 2 months ago by
Leo.
-
AuthorPosts
-
January 9, 2019 at 10:36 am #777508
Matt
I know this question has been asked before, but I just can’t figure out the best way to do it. If someone could take a look at my site and tell me what to do I’d really appreciate it.
I’d like to have the date appear as follows:
Posted Date: XXXXXX Updated Date: XXXXXX
I added my URL for the admins to see.
Thanks for the help!
January 9, 2019 at 3:03 pm #777709Leo
StaffCustomer SupportHi there,
Add this PHP snippet:
add_filter( 'generate_post_date_output', function( $output ) { $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_string . '<time class="updated" 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() ) ); echo sprintf( '<span class="posted-on">%1$s</span>', // WPCS: XSS ok, sanitization ok. sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>', esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ) ); } );
Adding PHP: https://docs.generatepress.com/article/adding-php/
And this CSS snippet:
.posted-on .updated { display: block; } .posted-on .updated + .entry-date { display: none; } .posted-on .updated:before { content: " Updated Date: "; } .posted-on .published:before { content: "Posted Date: "; }
Adding CSS: https://docs.generatepress.com/article/adding-css/
We are working on better methods to make this easier 🙂
January 10, 2019 at 7:08 am #778340Matt
Thanks, I add the PHP and CSS, but it doesn’t look right.
Can you please take a look at one of my blog post pages – there are some spaces missing.
Also, I would prefer to have the Last Updated date appear a line below the Posted date.
I also would like everything to appear below the featured image I think 🙂
Thanks for the help.
January 10, 2019 at 8:54 am #778443Leo
StaffCustomer SupportUpdated the CSS above.
January 10, 2019 at 9:01 am #778459Matt
Still doesn’t look right:
January 10, 2019 at 9:01 am #778460Leo
StaffCustomer SupportI’m still seeing the old CSS being added.
Have you tried clearing your caching plugin?
January 10, 2019 at 10:00 am #778511Matt
Yes, even cleared Cloudflare.
January 10, 2019 at 12:00 pm #778617Leo
StaffCustomer SupportI’m still seeing the old CSS being added in the source:
https://www.screencast.com/t/f9mQhpnTLooks like it’s added in Additional CSS in the customizer.
January 10, 2019 at 12:43 pm #778654Matt
Opps, forgot to delete what was there when I moved it over to the Simple CSS plugin 🙂
Almost done.
I would prefer to not display the date on tag or category pages:
https://www.yardcare.life/tag/buying-guide/
I think it looks funny.
January 10, 2019 at 4:29 pm #778761Leo
StaffCustomer SupportYou can either use this filter:
https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98date%E2%80%99Or this CSS:
.tag .posted-on, .tag .updated, .category .posted-on, .category .updated { display: none; }
January 11, 2019 at 7:07 am #779236Matt
Got it, thank you!
January 11, 2019 at 9:30 am #779360Leo
StaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.