Thumbs Rating 是一款非常简单实用的文章顶踩投票插件,支持文章、页面以及自定义文章类型。每个人每篇文章只能投票一次(通过HTML5 LocalStorage检测和限制)。

该插件默认没有自动在前台加载,你需要修改主题的源代码。
如果你想在文章的底部自动插入投票,可以在主题的 functions.php 文件添加下面的代码:
|
|
<span style="color: #000000; font-weight: bold;">function</span> thumbs_rating_print<span style="color: #009900;">(</span><span style="color: #000088;">$content</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">.</span>thumbs_rating_getlink<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> add_filter<span style="color: #009900;">(</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'thumbs_rating_print'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> |
|
function thumbs_rating_print($content)
{
return $content.thumbs_rating_getlink();
}
add_filter(‘the_content’, ‘thumbs_rating_print’);
如果你想自定义位置,你需要在循环(Loop)中添加相应代码来调用:
|
|
<span style="color: #000000; font-weight: bold;"><?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">(</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'thumbs_rating_getlink'</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span> thumbs_rating_getlink<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?></span> |
|
<?php if(function_exists(‘thumbs_rating_getlink’)) thumbs_rating_getlink(); ?>
如果你要在文章中列出投票最多的文章,你可以使用下面类似简码:
|
|
[thumbs_rating_top type="positive" posts_per_page="10" post_type="post" show_votes="no"] |
|
[thumbs_rating_top type="positive" posts_per_page="10" post_type="post" show_votes="no"]
更多的使用技巧,请查看官方FAQ:http://wordpress.org/plugins/thumbs-rating/faq/
在后台插件安装界面搜索 Thumbs Rating 即可在线安装,或者在这里下载 Thumbs Rating
赏 如果本文对你有帮助,请打赏作者,鼓励我们继续写作!
请先
!