AI摘要

本文介绍了子比主题文章页添加字数与阅读时间提示的美化教程,需在`functions.php`添加统计代码、在`zib-single.php`插入调用代码(提供默认与蓝色两套样式),并关闭后台图片封面设置即可实现。

在文章顶部添加一个文章字数和阅读时间的提醒,也算在一定程度上美化了主题吧~

效果图

两种效果,二选一即可!!

部署流程

1、在主题目录下 functions.php 或 func.php 文件把下面的代码添加进去:

[hidecontent type="reply"]
//  文章字数和阅读时间
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;
}
[/hidecontent]

2、在主题目录 /zibll/inc/functions/zib-single.php,

搜索下方代码(大概在312行),

注意:子比版本:7.9,其他版本自测

<div class="article-content">

把下方的代码放到搜索代码上方即可 (两张二选一)

默认样式

<!--文章字数和阅读时间-->
<i class="fa fa-hourglass-start"></i> <?php echo count_words_read_time(); ?>

蓝色字体

<span style="font-size: 18px; color: #00f; font-family: KaiTi"><?php echo count_words_read_time(); ?></span></p>

3、需要给子比后台设置的:图片封面关闭要不然不会显示(如图)