Wordpress插件wp-postviews及wp-postviews widget使用方法 - 杭州网站优化,百度推广,Google优化

Wordpress插件wp-postviews及wp-postviews widget使用方法

星期四, 一月 29, 2009 18:17
分类: WordPress

      WP-PostViews 和 WP-PostViews Widget 是WordPress 2.7 默认提供的插件,闲来无事,把它启用,感觉没效果,Google一下,才明白它的用处,写出来供大家参考。

      WP-PostViews插件 用来统计一篇文章阅读次数,配合 WP-PostViews Widget 在侧边栏实现显示阅读次数最多的文章或者页面、某分类下阅读次数最多的文章等,当前版本1.31,支持WordPress 2.7。

      如果你下载的是WordPress 2.7中文版,后台默认会有这两个插件,直接启用即可,后台没有的,点这里去下载1.31版,然后上传到wp-content/plugins/下面,然后在后台启用即可。

     启用以后,你仍然看不到效果,下面你找到wp-content/themes/你的主题/index.php(或者其他你要修改的文件如single.php,page.php等),找到这么一句代码:

       <?php while (have_posts()) : the_post(); ?>

       在后面合适的地方加上:

      

阅读次数:< ?php if(function_exists('the_views')) { the_views(); } ?>

      即可,恭喜你WP-PostViews插件已成功启用。下面介绍WP-PostViews Widget 插件的使用。

      首先你先确认的WP-PostViews 和 WP-PostViews Widget插件已经启用,如果你使用的主题支持Widget,在菜单外观下面点Widget进去,然后点添加,拖动wp-postviews Widget 到合适的位置即可。如果不支持,没关系,打开你的sidebar.php,把下面代码加到合适的地方。

1、显示阅读次数最多的文章或页面

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; ?>

如果你只想显示10篇阅读次数最多的文章,用下面的代码

1
2
3
< ?php if (function_exists('get_most_viewed')): ?> 
< ?php get_most_viewed('post',10); ?> 
< ?php endif; ?>

get_most_viewed 函数的第一个参数决定要显示的类别,可选 post ,page,both,第二个参数决定要显示的篇数。

如果你想显示显示某类别下的阅读次数最多的文章,用下面这段

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,第二个值是类别,可选both,page,post,第三个值决定要显示的篇数。

例如:显示分类ID为3下面阅读次数最多10篇文章

get_most_viewed_category(3, 'post', 10);

显示效果参看本站-攀登的SEO博客 ,不明白的地方欢迎留言交流。

添加到书签:
标签: , 阅读次数: 10,587

7 Responses to “Wordpress插件wp-postviews及wp-postviews widget使用方法”

  1. bmf says:

    十二月 24th, 2009 at 01:08

    好的,很好啊

  2. yph says:

    七月 30th, 2010 at 20:52

    不错,学习一下

  3. Jackeline Sails says:

    八月 26th, 2010 at 11:46

    This was a truly outstanding post. In theory I’d like to write like this also – getting time and real work to make a good write-up… but what can I say… I procrastinate alot and never seem to obtain some thing accomplished.

  4. 亿品元素 says:

    九月 2nd, 2010 at 19:49

    学习一下

  5. wmtimes says:

    九月 15th, 2010 at 12:48

    这个插件真的很不错。

  6. 网上赚钱的方法 says:

    九月 23rd, 2010 at 21:22

    不错的插件,安装了,谢谢分享!

  7. 左旋肉碱的减肥效果 says:

    十月 20th, 2010 at 02:45

    博主写的不错哈,继续加油,我订阅了你的博客。嘎嘎

发表评论