[Resolved] Help with function

Home Forums Support [Resolved] Help with function

Home Forums Support Help with function

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #823969
    epickenyan

    Hi Tom. I want to show this <div class="reading-time">Time To Read: <?php echo reading_time(); ?><div> next to the byline on single posts (and then float it right with CSS). Would you kindly help me with a function to do that? I want them to appear on a straight line because using the element after entry title does not help and I had to adjust the top margin using CSS which looks out of line on minimal devices.

    Here is the reading time function.

    function reading_time() {
        $content = get_post_field( 'post_content', $post->ID );
        $word_count = str_word_count( strip_tags( $content ) );
        $readingtime = ceil($word_count / 250);
    
        if ($readingtime == 1) {
          $timer = " minute";
        } else {
          $timer = " minutes";
        }
        $totalreadingtime = $readingtime . $timer;
    
        return $totalreadingtime;
    #824221
    David
    Staff
    Customer Support

    Hi there,

    try this CSS:

    .single-post .inside-article .entry-meta, .single-post .reading-time {
        display: inline-flex;
    }
    .single .byline {
        margin-left: 0.5em;
    }

    Then in your .reading-time CSS you can remove the float and add a margin-top: 0.5em;

    #826769
    epickenyan

    Hi. That inline-flex code is making my category, tags and navigation meta below posts to be broken. How to target only the meta at the top of the post?

    Solved footer.entry-meta {display:inline-block!important;}

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.