Estimated Reading Time
-
Hi
Estimated read time is working fine after the last resolution provided by Tom(), however, I am unable to fine tune it better. Let me explain.
Background:
Our main posts are in English. But we want to provide manual translations for 6 more languages. So far so good.Issue:
Estimated Read Time takes into account all the translated text instead of the original English one. This increases the Estimated Read time Value`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 );$text = ‘ minutes’;
if ( 1 == $time ) {
$text = ‘ minute’;
}return $time . $text;
}add_filter( ‘generate_post_date_output’, function( $output ) {
$output .= ‘<div class=”read-time”>Reading time: ‘ . tu_estimated_reading_time() . ‘</div>’;return $output;
} );Thanks in advance!
The page I need help with: [log in to see the link]
- The topic ‘Estimated Reading Time’ is closed to new replies.