首页 » 技术文档
WP-PostRatings文章评级的插件

  WP-PostRatings是一个由Lester ‘GaMerZ’ Chan制作的文章评级插件,可以在 这里 下载这个插件。

  下面给大家介绍下这个插件的使用:
  

1,安装

  在这里 这里 下载,将其中postratings文件夹解压倒wp-content/plugins目录下, 再 启用 此插件,即安装玩了。(这些用过wordpress的都知道)

2,使用

  打开主题里的(即目录wp-content/themes/<YOUR-THEME-NAME>/)的

index.php 首页每篇文章显示
single.php 单篇文章中显示
page.php 每个页面中显示
post.php 一般比较少,在贴出的文章中显示

  中,找到

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

  在这段代码下面任意地方(你想将 文章评级插件 放的地方),下面加入

<?php if(function_exists(‘the_ratings’)) { the_ratings(); } ?>

  这段代码

*#我是在index.php和single.php下加入了的代码,具体如下:

<?php the_content(‘Continue reading »’); ?>
<?php if(function_exists(‘the_ratings’)) { the_ratings(); } ?>我来投一票

  上面那行是首页显示文章内容的,下面那行是添加上去的 文章评级插件 的代码,我在后头加上的中文字是让它在PostRatings下面一起显示,懂些Html/Css,php语言的都能看懂。

  效果在我页面上可以看出来(可以将第二行内容改为 <?php if(function_exists(‘the_ratings’)) { the_ratings(); } ?>我来投一票<br> <br>,即在我来投一票下面加入一空白行,这样可以获得更好的显示效果)

  如果不再所有文章中显示 文章评级插件 ,请勿使用以上方法 ,只要在写的文章中或页面里写入 1 Star2 Stars3 Stars4 Stars5 Stars (10 votes, average: 1.6 out of 5)

Loading ... Loading …
即可,插件将只在此文章或页面中显示。

  1,显示 评价最高的文章

<?php if (function_exists(‘get_highest_rated’)): ?>
<ul>
<?php get_highest_rated(); ?>
</ul>
<?php endif; ?>

默认是第三行 <?php get_highest_rated(‘both’, 10);?>
其中值”both”是显示评价最高的文章和页面,值”10″是显示显示的数量,可自己更改;
改为”post”就只显示评价最高的文章;
改为”page”就只显示评价最高的页面;

  2,显示 分类中评价最高的文章

<?php if (function_exists(‘get_highest_rated_category’)): ?>
<ul>
<?php get_highest_rated_category(); ?>
</ul>
<?php endif; ?>

默认是第三行<?php get_highest_rated_category(0, ‘both’, 10);?>
其中值”0”是要显示的分类的ID(管理分类中可以查到),
值”both”和值”10″和上面的一样的,我就不罗嗦了

  3,显示 投票最多的文章

<?php if (function_exists(‘get_most_rated’)): ?>
<ul>
<?php get_most_rated(); ?>
</ul>
<?php endif; ?>

默认是第三行<?php get_most_rated(‘both’, 10);?>
  其中值”both”和值”10″和上面的一样的,我就不罗嗦了。

  转自Hammer Group,原文链接:这里

3 则留言 (访客:3 则, 博主:0 则)

 
 

留下评论


贴图

  

Additional comments powered by BackType

Improve the web with Nofollow Reciprocity.