Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

Adding a Post Rating System in WordPress with WP-PostRatings

Last updated on by
Elegant Themes
Adding a Post Rating System in WordPress with WP-PostRatings

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.

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

Once you have activated a plugin, a new tab will appear called “Ratings” with options for Managing Ratings, Ratings Options, and Rating Templates.

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

WP-PostRatings Rating Options Tab

In this page, you can select which rating image you want to use for your posts. They have bars, heart, numbers, plus-minus, the classic STARS, thumbs up/down, updown 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.

WP-PostRatings Rating Options Tab - Part 2

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.

WP-PostRatings Rating Widget

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.

Now if you notice in the image to your left, 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.

There were other rating plugins out there, but we found WP-PostRatings to be the simplest and the easiest to use for our basic purposes. Let us know if you like something different.

Download WP-PostRatings Plugin Now


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Anwar says:

    I don’t see it on your site anymore

    • Editorial Staff says:

      We are using a variation of this plugin to allow author rating (but no more user ratings).

  2. Mike Antkowiak says:

    Hey there great tutorial. I am using this plugin and I want to apply it to custom post types. Is there a way to add custom post types to the widget display?
    Thanks for you time.

  3. salem says:

    Hi
    Is their way to make plug-in files load from the theme
    I the my Site using Firebug Ysalow and find the loading.gif take long time to loading .

  4. R Thorp says:

    Thankyou! Solid advice, easy to folow guidance! However it would have been better if you included a little bit about adding the codes into the loop files, as i had to refer to other websites to find this.
    Cheers

  5. blue says:

    my jquery wont work because of this plugin.. :(

    • Editorial Staff says:

      Quite the opposite of a problem to have. jQuery doesn’t rely on this plugin. This plugin relies on jQuery.

  6. Shady M Rasmy says:

    i know its on old post and i don’t think i will get a reply on it
    but i will ask any way :D
    is there a way to collect the costume filed data for each user to show it in a page
    for logged in user
    example what i mean
    if i voted this post up
    and other posts
    can i show those posts later from page my likes for example ?
    sorry bad English :)

  7. محمد جبران says:

    Thanks for the great instruction. Though the latter link gives 404

  8. wpbeginner says:

    There must be some issue with how the plugin is entering the code. You can always disable the normal integration, and paste the code directly in your template.

  9. Anna747 says:

    I added the codes to the files listed but the ratings were showing up at the bottom of my page below the footer instead of below the post? I only want them below the post, not on my pages/homepage…and right below the post.

    • arbitrarylifestyle says:

      You’d want to find out the specific place you want the ratings to show up. For example, mine show up just beside the title so I put my code next to the title as so:

      Yeah!!!

  10. Shad says:

    Awhile back I was conceptualizing a site for short-story authors. The member would submit a story(post) and the other members would critique the story (as comments).

    What I was looking for then, and what is similar to this post, is a way for the original author to select comments as helpful (as in an thumbs up with note that said “Author found this comment helpful”). Has anyone seen anything such as that? Where the actual comments are rated?

    • Auz says:

      I am currently using GD Star Rating for our rating system. It has been very flexible, but probably a little more advanced than wp-postratings. It does have the ability to allow comment ratings. For an example check out our site (www.bendbeerblog.com)

      I eventually want to connect the ratings with the untappd.com API. I am hoping I can hook into the system, but if not I may have to write a custom solution.

  11. Keith Davis says:

    Plugin looks great but I’m trying to cut down the number of plugins that I use.

    It’s all too easy to just keep adding plugins.

    Thanks for another great tut.

  12. Connor Crosby says:

    Awesome! I wonder if they use this or something similar for the tuts+ network.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.