Fixed this by creating my own filter instead of using a plug-in.
add_filter( 'render_block', function( $block_content, $block ) {
if (!is_admin() && ! empty( $block['attrs']['className'] ) && 'reading-time' === $block['attrs']['className']){
$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 = $word_count / $wpm;
if($time > 1) {
$suffix = 'minutes';
} else {
$suffix = 'minute';
}
if($time < 1) {
$time = '< 1';
} else {
$time = ceil( $word_count / $wpm );
}
$block_content = '<span class="read-time">Reading time: ' . $time .' '. $suffix . '</span>';
}
return $block_content;
}, 10, 2 );
Credit to: https://generatepress.com/forums/topic/add-reading-time-on-posts-after-the-author-name/
-
This reply was modified 1 year, 10 months ago by JJCoding.