wp-postviews及wp-postviews widget官方下载及使用方法

WP-PostViews是一个wordpress的日志浏览记录统计插件,我目前知道的唯一一个这样功能的插件,个人认为也是目前为止使用率最高的一个插件,我做了一下汉化,不知道翻译成日志浏览插件对不对,如果欠妥的话请指正,还有还是那句话,如果使用过程中觉得有些翻译欠妥的话也请指正。
下面简要说一下改插件的功能,个人发现只要启用该插件以后,不管你在不在模板添加显示代码,只要有人浏览你的日志文章,该插件就会在数据库记录的·
一,WP-PostViews安装方法
1.下载安装WP-PostViews,目前最新版本是1.40,解压后上传至wp-content/plugins;如果你下载的是WordPress 2.7中文版,后台默认会有这两个插件,直接启用即可,后台没有的,点这里去下载1.31版,然后上传到wp-content/plugins/下面,然后在后台启用即可。
目录
2.至插件管理页激活该插件
3.在你的single.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);

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

本站文章欢迎转载。转载请注明:转载自迷失曾经谢谢!
原文链接地址:wp-postviews及wp-postviews widget官方下载及使用方法 Tags:

热门网购