第一步
在主题目录下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/300); // 修改数字300调整时间
$output .= '共计' . $text_num . '字,阅读大约' . $read_time . '分钟。';
return $output;
}
第二步
在主题目录zibll/inc/functions/zib-single.php,把下面代码添加到260行处(如下图)
(温馨提示:由主题不断更新放的位置也有可能不同,目前显示主题版本:V5.6,如网站更新自行查找放置)
<!--文章字数和阅读时间--><i class="fa fa-hourglass-start"></i> <?php echo count_words_read_time(); ?>
![图片[1]-WordPress文章页面添加文章字数和阅读时间-乡野博文](http://www.zau.cn/wp-content/uploads/2022/02/31a49099e6e5-12-1024x523.png)
第三步
温馨提示需要给子比后台设置的:图片封面关闭要不然不会显示(如图)
![图片[2]-WordPress文章页面添加文章字数和阅读时间-乡野博文](http://www.zau.cn/wp-content/uploads/2022/02/31a49099e6e5-13-1024x439.png)
您阅读这篇文章共花了: 0小时00分00秒
THE END
暂无评论内容