Site logo

Archived topic

Show Reading time on WP Show Posts (home page)

4 replies · Started by Charbel on November 1, 2021

Viewing posts 1–5 of 5

Hello @David and @Leo,

I am using an Element to display the estimate reading time on every article (post).

Here is PHP code from the Element (generate_after_entry_title):

<?php
function custom_estimated_reading_time() {
    global $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 . ' Min. ';
}
?>
<div class="read-time"><?php echo custom_estimated_reading_time() ; ?>Read</div>

How can I use the same Element to display it on WP Show Posts next to the Author name (right side)?
The author name is on the left, I need to add the estimate reading time on the right-hand side.

Your help is highly appreciated.

Article: https://charbelnemnom.com/passing-the-azure-security-center-ninja-training/

Many Thanks!
-Charbel

Even better.

Elvin will get to it later.

Thanks!

Super, many thanks!

This archived topic is closed to new replies.