有时候想知道自己WordPress博客的文章被点击或浏览了多少次,然后对其进行热门文章排行推荐给读者,但据博客吧所知WordPress默认并没有这个功能,所以需要用到WordPress博客插件来实现,博客吧推荐使用的浏览数量统计的插件是非常受欢迎的WP-PostViews插件。
WP-PostViews插件介绍:
该插件由 GaMerZ 开发,主要是实现单篇文章阅读数量统计、显示浏览数量最多文章排行、分类下浏览数量最多的文章排行等功能效果。
WP-PostViews插件安装:
WP-PostViews插件使用一:
方法一
方法二
在主题文件sidebar.php文件中的相应位位置添加代码
1 2 3 | <?php if (function_exists('get_most_viewed')): ?> <?php get_most_viewed(); ?> <?php endif; ?> |
1 2 3 | <?php if (function_exists('get_most_viewed')): ?> <?php get_most_viewed('post'); ?> <?php endif; ?> |
1 2 3 | <?php if (function_exists('get_most_viewed')): ?> <?php get_most_viewed('post',10); ?> <?php endif; ?> |
在get_most_viewed 函数中的参数10决定要显示的篇数
1 2 3 | <?php if (function_exists('get_most_viewed_category')): ?> <?php get_most_viewed_category(the_catagory_ID(false)); ?> <?php endif; ?> |
在get_most_viewed_category函数类别ID决定显示的分类
1 2 3 | <?php if (function_exists('get_most_viewed_category')): ?> <?php get_most_viewed_category($cat,'post',5); ?> <?php endif; ?> |
在get_most_viewed_category函数类别ID决定显示的分类
1 2 3 | <?php if (function_exists('get_most_viewed_category')): ?> <?php get_most_viewed_tag($tag_id,'post',5); ?> <?php endif; ?> |
WP-PostViews插件使用二:
在文章中显示该文章的浏览数量
1 | <?php if(function_exists('the_views')) { the_views(); } ?> |
提示:文章中显示的“热度”可根据自己的想法创新!
转载于:
本文发布于:2024-02-04 06:04:29,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170700623952926.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |