使用WP-PostRatings在WordPress中添加帖子评级系统

We were recently looking to incorporate a simple post rating system in our project and had to deal with numerous plugins. After going through several, we found the one that works best for adding a post rating system in WordPress was “WP-PostRatings” by Lester ‘GaMerZ’ Chan. In this article, we will walk you through setting up an AJAX rating system for your WordPress blog posts and pages.

我们最近正在寻求在项目中纳入一个简单的后评价系统,并且不得不处理许多插件。 经过几遍之后,我们发现最适合在WordPress中添加帖子评级系统的一个是Lester'GaMerZ'Chan撰写的WP-PostRatings ”。 在本文中,我们将引导您为WordPress博客文章和页面建立AJAX评分系统。

影片教学 (Video Tutorial)

演示地址

If you don’t like the video or need more instructions, then continue reading.

如果您不喜欢该视频或需要更多说明,请继续阅读。

First you need to download and activate the WP-PostRatings Plugin (For beginners: Step by Step Guide to Installing a WordPress Plugin)

首先,您需要下载并激活WP-PostRatings插件 (对于初学者: 安装WordPress插件的分步指南 )

Upon activation, the plugin will add a new menu item in your WordPress admin bar labeled ‘Ratings’.

激活后,该插件将在WordPress管理栏中添加一个名为“ Ratings”的新菜单项。

We will skip the “Managed Ratings” option, and start out with the second link in the tab called “Rating Options”.

我们将跳过“管理的评分”选项,并从“评分选项”标签中的第二个链接开始。

WP Post Ratings settings page

On the plugin’s settings page, first you need to select which rating image you want to use for your posts. The plugin comes with a number of options like bars, heart, numbers, plus-minus, the classic stars, thumbs up/down, up-down arrows, etc.

在插件的设置页面上,首先您需要选择要用于帖子的评分图像。 该插件带有许多选项,例如条形,心形,数字,正负号,经典星号,拇指向上/向下,向上箭头等。

Once you have picked the rating system that you like, you can select the “Max Ratings”. The plugin will pick an appropriate value for you, but when using bars image, you may want to specify your own value of rating. For stars and numbers it seems pointless to go over 5 because there are only 5 stars.

选择所需的评分系统后,您可以选择“最高评分”。 该插件将为您选择一个合适的值,但是在使用条形图时,您可能需要指定自己的等级值。 对于星星和数字,超过5个似乎毫无意义,因为只有5个星星。

Remember, if you do adjust the Max Ratings, you will need to adjust the Individual Rating Text/Value. If you do not change the Max Rating value from default, then leave the Individual ratings to be default as well.

请记住,如果您确实调整了最高评分,则需要调整个人评分文字/值。 如果您没有将“最大额定值”从默认值更改,则将“单个额定值”也保留为默认值。

Then you will see the option for Ajax Style, Rating Permission, and Logging Method.

然后,您将看到Ajax样式,评级权限和记录方法的选项。

Ratings Ajax Style and logging method

You can follow the styling in the image above for best results. However if you want to customize, you may need to change these.

您可以按照上面图像中的样式进行操作以获得最佳效果。 但是,如果要自定义,则可能需要更改它们。

We are done with this page, save the changes. Let’s move onto the “Ratings Templates” page. On this page, you will see different rating templates and how you want to organize them. We left them with the default value, but you are more than welcome to utilize the Template Variables on top of the screen to modify them. This is basically to show how your ratings will be displayed. Once you are done with the “Ratings Templates” page, you are ready to add this in your theme.

我们完成了此页面,保存更改。 让我们进入“评分模板”页面。 在此页面上,您将看到不同的评分模板以及如何组织它们。 我们为它们保留了默认值,但是非常欢迎您使用屏幕顶部的模板变量来修改它们。 这基本上是为了显示您的收视率如何显示。 完成“评分模板”页面后,即可将其添加到主题中。

Depending on how your theme is setup, you will need to add the following codes within the LOOP in the following files (archives.php, page.php, index.php, single.php, loop.php etc) – You may not have all of these files in your theme depending on the structure.

根据主题的设置方式,您需要在以下文件(archives.php,page.php,index.php,single.php,loop.php等)的LOOP中添加以下代码。主题中的所有这些文件都取决于结构。

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

Note, this will add the post rating to all posts. If you just want to use it on selective posts, you can utilize the shortcode [ratings id=”1″ results=”true”] to display the ratings on just that post or page.

请注意,这会将帖子评分添加到所有帖子。 如果您只想在选择性帖子上使用它,则可以使用简码[ratings id =” 1” results =” true”]在该帖子或页面上显示评分。

Now that you have ratings added, your users will be voting on your posts. You can view those ratings from the “Manage Ratings” option that we skipped initially. This allows you to see a log of ratings on each post, and you can delete them as well if you feel that there is something wrong going on.

现在您已经添加了评分,您的用户将对您的帖子进行投票。 您可以从我们最初跳过的“管理评分”选项中查看那些评分。 这样一来,您就可以查看每个帖子的评分日志,并且如果感觉出问题了,也可以删除它们。

The best part about this plugin is that it has an ability to show the Highest Rated Posts (option for time range and category), Most Rated Posts (option for time range and category), Lowest Rating and Highest rating with the same option of time range and category. Most of the times, these type of stats are added in the sidebar, so this plugin allows you to utilize the Widgets to display these (only if your theme support widgets – Most DO!). Simply go to Appearence » Widgets and find the Ratings widget. Drag it in the appropriate location and set the settings you want.

关于此插件的最好之处在于,它能够显示具有相同时间选项的最高评分帖子(时间范围和类别的选项),最高评分帖子(时间范围和类别的选项),最低评分和最高评分范围和类别。 在大多数情况下,这些类型的统计信息会添加到边栏中,因此,此插件可让您利用小部件来显示这些状态(仅当您的主题支持小部件–最多!)。 只需转到外观»小部件,然后找到“评级”小部件。 将其拖动到适当的位置,然后设置所需的设置。

Ratings widget options

Now if you notice in the above screenshot, there are bunch of options. First is to select the title of your widget. It is best to select like “Most Rated Posts This Week” or something. Depending on how you do rest of your settings. Statistic Type field has tons of options which allow you to show Highest Rated, Most Rated, Lowest Rating, and Highest Rating. You also have the option to pick these stats by category or by time. The next option asks whether you want to include both your posts and pages. This is entirely a personal choice. So pick as you like. The widget shows 10 most popular entires by default, but it can be changed by editing the No. of Records to Show. We strongly recommend that you don’t make it more than 10 because it just looks bizarre with most designs. You can also set the number of minimum votes a post needs to have before it can make it into this list. Depending on your site design, you may or may not want to adjust the Maximum Post Title length. If your theme location is wide enough, we recommend that you set the value to 0 to disable it. If you are using the Category or Time specific statistic type, then you would need to modify the last two fields. Click and save and you are done.

现在,如果您在上面的屏幕截图中注意到,则有很多选项。 首先是选择窗口小部件的标题。 最好选择“本周评分最高的帖子”之类的东西。 取决于您如何进行其余设置。 “统计类型”字段具有大量选项,可让您显示“最高评分”,“最高评分”,“最低评分”和“最高评分”。 您还可以选择按类别或时间选择这些统计信息。 下一个选项询问您是否要同时包含帖子和页面。 这完全是个人选择。 所以随便选。 该小部件默认显示10个最受欢迎的整体,但可以通过编辑要显示的记录数进行更改。 我们强烈建议您不要使它超过10,因为在大多数设计中它看起来都很奇怪。 您还可以设置帖子进入该列表所需的最低投票数。 根据您的站点设计,您可能会或可能不想调整“最大帖子标题”长度。 如果主题位置足够宽,我们建议您将该值设置为0以将其禁用。 如果使用类别或时间特定的统计信息类型,则需要修改最后两个字段。 单击并保存,您就完成了。

Now we know that some of you are code junkies and do not want to use the widget settings. Lester has compiled a very detailed Usage Tab on his site which explains how to add the most rated, highest rated etc. directly into your WordPress Themes. Refer to WP-PostRatings Usage Guide.

现在我们知道你们当中有些是代码迷,不想使用小部件设置。 Lester在他的网站上整理了一个非常详细的“用法”选项卡,其中说明了如何将评分最高,评分最高的等直接添加到您的WordPress主题中。 请参阅WP-PostRatings使用指南

We hope this article helped you add a post rating system on your WordPress site. You may also want to take a look at our guide on how to engage readers with post reactions in WordPress.

我们希望本文能帮助您在WordPress网站上添加帖子评级系统。 您可能还想看看我们的指南,了解如何使读者参与WordPress中的后React

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/adding-a-post-rating-system-in-wordpress-with-wp-postratings/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值