WordPress主题怎么添加文章字数和阅读时间
特别是阅读时间,'', 写完这篇文章,html_entity_decode(strip_tags($post-post_content)))。
$zm_format); $words = mb_strlen(preg_replace('/\s/',发现网上有更简洁的代码。
默认是按CCTV广播员语速定的,不过有用户说人家有我们能不能也加一个。
文章阅读时间 // 阅读时间 function zm_get_reading_time($content) { $zm_format = 'span阅读时间%min%分%sec%秒/span'; $zm_chars_per_minute = 300; // 估算1分种阅读字数 $zm_format = str_replace('%num%',''。
'; return $output; } 调用代码: ?php echo count_words_read_time(); ? 以上就是为WordPress主题添加文章字数和阅读时间的详细内容,这功能有什么用呢, $zm_format)); } function zm_reading_time() { echo zm_get_reading_time(get_the_content()); } 代码添加到当前主题函数模板 functions.php 中, 'UTF-8') mb_strlen($text,下面的代码只估算到分, 'UTF-8')) $output .= 'span共' . mb_strlen(preg_replace('/\s/',更多请关注网站的其它相关文章! ,html_entity_decode(strip_tags($content)))。
区别是上面的代码精确到秒, function count_words_read_time () { global $post; $text_num = mb_strlen(preg_replace('/\s/', $seconds, 不过字数统计和阅读时间不是很精确。
'UTF-8'); $read_time = ceil($text_num/300); // 修改数字300调整时间 $output .= '本文共计' . $text_num . '个字,预计阅读时长' . $read_time . '分钟, $minutes,'UTF-8'); $minutes = floor($words / $zm_chars_per_minute); $seconds = floor($words % $zm_chars_per_minute / ($zm_chars_per_minute / 60)); return str_replace('%sec%'。
我也不知道,下面由 WordPress教程 栏目给大家介绍为WordPress主题添加文章字数和阅读时间的方法,html_entity_decode(strip_tags($post-post_content))),那就加吧,更是扯淡。
$zm_chars_per_minute, 调用文章字数和阅读时间代码 显示文章字数代码: ?php echo zm_count_words($text); ? 显示阅读时间代码: ?php zm_reading_time(); ? 将上述调用代码加到当前主题正文模板的适当位置即可。
'', 显示文章字数和阅读时间, 为WordPress主题添加文章字数和阅读时间为WordPress主题添加文章字数和阅读时间 具体代码这里也分享一下: 文章字数统计 // 字数统计 function zm_count_words ($text) { global $post; if ( '' == $text ) { $text = $post-post_content; if (mb_strlen($output,'UTF-8') .'字/span'; return $output; } } 代码添加到当前主题函数模板 functions.php 中。
str_replace('%min%',。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jz/wp/10886.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
ludou_se_only); } add_action(s
时间:2021-01-23
-
所以经常导致输错密码的
时间:2021-01-23
-
WordPress措施打开速度慢的
时间:2021-01-22
-
WordPress回覆评论自动添加
时间:2021-01-22
-
我们可以通过下面的代码
时间:2021-01-22
-
如何修改WordPress默认脚色
时间:2021-01-20
-
同样的修改文件就行
时间:2021-01-20
-
少数善意的转载者既使没
时间:2021-01-20
热门文章
-
WordPress新手安装教程(图文)
时间:2020-12-28
-
在设置菜单中增加WordPress私密 隐藏的全部
时间:2021-01-10
-
WordPress博客程序常见错误的解决方法
时间:2020-12-28
-
WordPress程序打开速度慢的三种解决方法
时间:2021-01-10
-
wordpress使用代码在每篇文章尾部添加版权
时间:2020-12-14
-
WordPress博客措施常见错误的办理要领
时间:2021-01-15
-
关于WordPress的SEO优化相关的一些PHP页面脚
时间:2021-01-07
-
WordPress措施打开速度慢的三种办理要领
时间:2021-01-22
-
详解WordPress中的头像缓存和署理中的缓存
时间:2021-01-15
-
少数善意的转载者既使没有看到版权信息
时间:2021-01-20
