Creates a simple reading-time shortcode based on the current post content and an average 200 words per minute pace.
add_shortcode( 'reading_time', 'wpfolks_reading_time_shortcode' );
function wpfolks_reading_time_shortcode() {
$word_count = str_word_count( wp_strip_all_tags( get_post_field( 'post_content', get_the_ID() ) ) );
$minutes = max( 1, (int) ceil( $word_count / 200 ) );
return esc_html( sprintf( '%d min read', $minutes ) );
}