[Resolved] Reading Time Help needed

Home Forums Support [Resolved] Reading Time Help needed

Home Forums Support Reading Time Help needed

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1603055
    Jerry

    Hi guys,
    I have used this code to add estimated reading time to be added.

    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 );
        
        if ($time == 1) {
            return $time . ' min read';
        } else {
            return $time . ' mins read';
        }
    }
    add_action( 'generate_post_meta_items', function( $item ) {
        if ( 'reading-time' === $item ) {
            echo '<span class="reading-time"> ' . tu_estimated_reading_time() . '</span>';
        }
    } );
    
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'date',
            'reading-time',
        );
    } );
    

    It is almost doing what I like it to do. However, I’d like to add space between the “date” and the byline.

    The “byline” and “time left to read” has that space so essentially I’d like to achieve this:

    DATE SPACE BYLINE SPACE READ_TIME

    You can see it here if needed, thank you guys!
    https://tinyurl.com/y7l3alv7

    http://jeroenc2.sg-host.com/blog/

    #1603570
    David
    Staff
    Customer Support

    Hi there,

    i am not seeing the author byline in the meta ? So do you just want more space between the date | reading time ? If so edit this CSS:

    .byline, .posted-on, .comments-link {
        border-right: 2px solid #ddd;
        padding-right: 1px;
    }

    And increase the padding-right: 1px; to 5px or whatever space you need.

    Let me know.

    #1603898
    Jerry

    Hi David,
    Yes that worked. Sometimes the simplest things are right under your nose, thank you!

    #1603914
    David
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.