有时候想知道本身WordPress博客的文章被点击或浏览了多少次,而后对其进行热门文章排行推荐给读者,但据博客吧所知WordPress默认并无这个功能,因此须要用到WordPress博客插件来实现,博客吧推荐使用的浏览数量统计的插件是很是受欢迎的WP-PostViews插件。php
WP-PostViews插件介绍:ide
该插件由 GaMerZ 开发,主要是实现单篇文章阅读数量统计、显示浏览数量最多文章排行、分类下浏览数量最多的文章排行等功能效果。wordpress
WP-PostViews插件安装:函数
WP-PostViews插件使用一:工具
方法一post
方法二.net
在主题文件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决定要显示的篇数3d
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决定显示的分类blog
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(); } ?> |
提示:文章中显示的“热度”可根据本身的想法创新!