//定义字数和时间计算
function wpcount_words_read_time () {
global $post;
$text_num = mb_strlen(preg_replace('/\s/','',html_entity_decode(strip_tags($post->post_content))),'UTF-8');
$read_time = ceil($text_num/400);
$output .= '共' . $text_num . '个字,预计阅读需' . $read_time . '分钟';
return $output;
}然后根据需要的位置添加调用。
<?php echo wpcount_words_read_time(); ?>这里是根据每分钟400字的阅读速度计算的,我们也可以根据其他频率计算。