Archived topic
Estimated Read Time in Author box
3 replies · Started by J. on January 18, 2022
Viewing posts 1–4 of 4
Hi there,
you can use this PHP Snippet:
function tu_estimated_reading_time() {
$post = get_post();
$content = $post->post_content;
$wpm = 250; // 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';
}
add_shortcode('reading-time', 'tu_estimated_reading_time');
This will create the following shortcode that you can add to your element:
[reading-time]
Clear, thank you!
Glad to be of help
This archived topic is closed to new replies.