- This topic has 5 replies, 2 voices, and was last updated 1 year, 6 months ago by
Tom.
-
AuthorPosts
-
August 20, 2019 at 8:50 am #989032
Katja
Hello GP Team,
I would like to add the Reading Time WP shortcode to the date output and saw the snippet provided by Tom on the following page.:
https://generatepress.com/forums/topic/add-time-to-read-in-meta-date/Unfortunately this doesn’t work for me. Instead the shortcode itself is displayed after the date.
I would like the time to be displayed in this area if possible as it keeps the meta info to one line.
Thanks for any pointers.
Best wishes,
Roger
August 20, 2019 at 5:12 pm #989295Tom
Lead DeveloperLead DeveloperHi there,
Try this:
add_filter( 'generate_post_date_output', function( $output ) { return $output . do_shortcode( '[rt_reading_time]' ); } );
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 21, 2019 at 1:39 am #989448Katja
Hello Tom,
that now works – thanks for your help with that.
I had another snippet from you that was also targeting the date output. the snippet made it so the date was no longer hyperlinked. (https://docs.generatepress.com/article/generate_post_date_output/#only-show-updated-date). When this snippet was active the one you provided above obviously didn’t work, works fine when that one is deactivated.
If it’s possible to combine the two, i.e. to have the date not hyperlinked and the reading time shortcut included that would be a great solution for me. If not, I’ll leave the date hyperlinked and keep the reading time.
Thanks Tom for your brilliant service and responsiveness as always.
Best wishes,
Roger
August 21, 2019 at 9:26 am #989906Tom
Lead DeveloperLead DeveloperLet’s give this a shot instead:
add_filter( 'generate_post_date_output', function( $output, $time_string ) { $output = sprintf( '<span class="posted-on">%s</span>', $time_string ); return $output . do_shortcode( '[rt_reading_time]' ); }, 10, 2 );
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 22, 2019 at 7:56 am #990761Katja
Tom,
that works a treat. Thanks very much for your help.
You are just the best.
Roger
August 22, 2019 at 6:34 pm #991158Tom
Lead DeveloperLead DeveloperNo problem! Glad I could help π
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.