上午发布了WP-PostViews这个插件的中文版,有需要的可以了解一下。现在说一下这个文章统计插件的使用方法,这款插件需要我们手动添加代码。
首先是最常用的一种,你可以在你主题里面的archive.php, single.php, post.php 或者
page.php等等找到<?php while (have_posts()) : the_post();
?>然后在它下面你需要显示的地方输入
<?php
if(function_exists('the_views')) { the_views(); }
?>
这样我们就可以在页面上显示出统计数量了。
另外一种情况就是不在主题的Loop循环中,我们想放在任意一个地方。这时候需要使用下面的这些方法。
1.最新浏览过的文章统计排名
1 |
<?php if (function_exists( 'get_least_viewed' )): ?> |
3 |
<?php
get_least_viewed(); ?> |
6 |
//* 第一个参数选择统计范围, 'post', 'page' or
'both'.文章,页面,全部 |
8 |
//* 默认使用方法: get_least_viewed('both',
10); |
2.最受欢迎的文章统计(即:浏览次数最多的)排名
1 |
<?php if (function_exists( 'get_most_viewed' )): ?> |
3 |
<?php
get_most_viewed(); ?> |
7 |
//* 第一个参数选择统计范围, 'post', 'page' or
'both'.文章,页面,全部 |
9 |
//* 默认使用方法: get_most_viewed('both',
10) |
3.最新浏览标签下的文章统计排行
01 |
<?php if (function_exists( 'get_least_viewed_tag' )): ?> |
03 |
<?php
get_least_viewed_tag(); ?> |
08 |
//* 第二个参数选择统计范围, 'post', 'page' or
'both'.文章,页面,全部 |
10 |
//* 默认使用方法: get_least_viewed_tag(1, 'both',
10); |
4.浏览最多标签下的文章统计排行
01 |
<?php if (function_exists( 'get_most_viewed_tag' )): ?> |
03 |
<?php
get_most_viewed_tag(); ?> |
08 |
//* 第二个参数选择统计范围, 'post', 'page' or
'both'.文章,页面,全部 |
10 |
//* 默认使用方法: get_most_viewed_tag(1, 'both',
10); |
5.显示最新浏览分类下的文章统计排行
01 |
<?php if (function_exists( 'get_least_viewed_category' )): ?> |
03 |
<?php
get_least_viewed_category(); ?> |
08 |
//* 第二个参数选择统计范围, 'post', 'page' or
'both'.文章,页面,全部 |
10 |
//* 默认使用方法:
get_least_viewed_category(1, 'both', 10); |
6.显示浏览最多分类下的文章统计排行
01 |
<?php if (function_exists( 'get_most_viewed_category' )): ?> |
03 |
<?php
get_most_viewed_category(); ?> |
08 |
//* 第二个参数选择统计范围, 'post', 'page' or
'both'.文章,页面,全部 |
10 |
//* 默认使用方法: get_most_viewed_category(1,
'both', 10); |
7.根据浏览数量来进行排序
1 |
<?php
query_posts( 'v_sortby=views&v_orderby=desc' )
?> |
4 |
//v_orderby 排序的顺序 倒序(desc)和升序(asc) |
以上几点就是WordPress文章统计插件(WP-PostViews)使用方法了.
加载中,请稍候......