Adding a Post Rating System in WordPress with WP-PostRatings

139

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.

Video Tutorial

Subscribe to WPBeginner

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)

Upon activation, the plugin will add a new menu item in your WordPress admin bar labeled ‘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.

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.

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.

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

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.

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.

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.

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.