以下代码放入b2/functions.php
function count_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;
}
打开\b2\TempParts\Single目录
众所周知B2有5中文章样式,在合适位置自行引入代码到你需要的样式。
<?php echo count_words_read_time(); ?>