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/