Site logo

Archived topic

Reading Time Dynamic Field in Post Meta

11 replies · Started by Puneet on April 28, 2022

Viewing posts 1–12 of 12

Hi
I am using Post meta as the image below.

https://snipboard.io/cZ62oA.jpg

post link: https://manoftech.com/wordpress-com-review/

I just need to add reading time to it. I used the filter below given by Tom from another post.

`

    function tu_estimated_reading_time() {
    $post = get_post();
    $content = $post->post_content;
    $wpm = 300; // How many words per minute.

    $clean_content = strip_shortcodes( $content );
    $clean_content = strip_tags( $clean_content );
    $word_count = str_word_count( $clean_content );
    $time = ceil( $word_count / $wpm );

    return $time . ' minutes';
    }

    add_filter( 'generate_post_date_output', function( $output ) {
    $output .= '

    Reading time: ' . tu_estimated_reading_time() . '

    ';

    return $output;
    } );

The question is, how do I add reading time to the post meta designed using the dynamic option in elements via generateblocks?

Regards,
Puneet

It's showing with a shortcode, but how do I control the padding around it within generateblocks element. I would need a bit of padding on the left.

Add the shortcode inside of a GB Headline Block, the output from the shortcode will respect the headline blocks styles

Hi David,
Thanks again. It worked perfectly. Though I wonder why I couldn't think of that...lol. I have a lot to learn clearly. Thanks a ton again.

Regards,
Puneet

Glad to be of help!

Oops,
Sorry, I forgot to ask another query. If I add social icons from the generateblocks template library, what URL do I add to them to make them social share icons and not follow buttons? We can use Facebook and Twitter as an example here. Thanks,

Regards,
Puneet

Unfortunately thats not possible. You would need to use a social sharing plugin for that.

I am using a social sharing plugin. I was thinking of adding a custom button near the featured image or with the post meta. Something like this:-

https://snipboard.io/9j7g45.jpg

I can place the icons but don't know how to use them as share buttons.

Regards,
Puneet

The Icons added by a GB Button or Headline block can only link to static URLs, they can't be converted to social shares without hijacking them with some Javsascript which is out of our scope.

Just add your social share icons using the plugin shortcode - if need be i can help with some CSS to position them

Thanks David,
Probably get to it later. Thanks again,

Regards,
Puneet

You're welcome

This archived topic is closed to new replies.