Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

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.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

53 CommentsLeave a Reply

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Kyle

    Hi I am very new to WP and can’t seem to figure out how to add the code to the LOOP in archives.php, page.php, index.php, single.php, loop.php etc. Can you please provide a little guidance?
    Thank you

    • WPBeginner Support

      If you reach out to your specific theme’s support they should be able to assist with locating the loop in your theme.

      Admin

  3. Ivan

    Hi, is there a option to rate with a ‘half star’ ?, i saw there is a picture showing ‘half star’ , thanks

    • WPBeginner Support

      You can create custom icons if you want but the half stars are normally for the average for the rating

      Admin

  4. Rohit jha

    Awesome! Your Every blog are very Very useful for us…

    • WPBeginner Support

      Glad you found our guide useful :)

      Admin

  5. Shoaib Saleem

    Hi,
    How to get top rated posts in WordPress? I am using custom code to rate post with comments. The rating value is storing in comment meta table.I need help to get 5 top rated posts.
    Thanks

    • WPBeginner Support

      You would want to take a look at the plugin’s FAQ for the answer to this question :)

      Admin

  6. Radu Giurgiu

    Hello!

    It is a good general information about this rating plugin, with is good.
    But… what happen if the user what to re-star (rating) the post?
    Seems the plugin not allowing tho let the user change his opinion about a specific post. Wich is very important.

    There is a solution for that?

    • WPBeginner Support

      For that, you would want to reach out to the plugin’s support to see if that could be a feature to add

      Admin

      • Radu Giurgiu

        Yes of course.

        Ok. Thanks!

  7. Riyaz Shaikh

    Thank you for sharing this article. Was of great help, I was struglling with this since months, but and today could install Rating plug in on webpage.

    Thanks to you

  8. Faruk

    I cant change the visuality, i mean stars

  9. Umang

    We have recently implemented the rating plugin on our company’s blog posts and it is work like a charm.

    Google Rich Snippets setting is also a great option but I think it should be enabled by default.

    Thanks for sharing such a useful plugin.

  10. Carlos

    How can I make the stars show up in the SERPS?

  11. Dmitry

    what is PHP function or shortcode to show ratings of a post ID?

  12. Gobind Singh

    I’m trying to run that plugin in local server. The stars have shown up in my post but I’m not able to do rating. How can I solve this problem? Please help me..

  13. Gail Palubiak

    It sounds interesting but I found your explanation inadequate.

    “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.”

    Most information please.

  14. surya JD

    hey thanks but as I know this plugin won’t work with any cache plugin.
    But on your blog you are using this plugin with w3 total cache . right ?
    what tricks you used to work this plugin with cache plugins…

  15. vinod

    it is a great wordpress plugin

  16. Boby Kurniawan

    The stars is show up, but the stars cannot be clicked . Sorry for bad english

    • surya JD

      May be you are using any cache plugin on your site. this plugin won’t work with cache plugin.

  17. Mathias

    Could you guys please help me??? I don’t get that plugin to sort posts by rating on my homepage… I’m a total beginner in coding… where exactly do I have to put which lines of code to sort my posts by rating??? Please help me!

    • WPBeginner Support

      You need to add the code in your theme’s template files inside the WordPress Loop.

      Admin

      • GTMan

        Actually which code do we need to add in loop?

      • Doro

        No longer available. Any alternative? :-)

    • Valter Cardoso

      I was wondering the same thing. I am trying to make a voting system that the most posted categories will be arranged on top of the post. Can someone help me how to do this, please? Here’s the site I am building with this concept

  18. Anwar

    I don’t see it on your site anymore

    • Editorial Staff

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

      Admin

  19. Mike Antkowiak

    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.

    • surya JD

      yes If you created post template for custom post type aka CPT you can add
      in post loop.
      if you already don’t have custom template for CPT you can create in your theme folder or in child theme of main theme.

  20. salem

    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 .

  21. R Thorp

    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

  22. blue

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

    • Editorial Staff

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

      Admin

  23. Shady M Rasmy

    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 :)

  24. wpbeginner

    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.

  25. Anna747

    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

      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!!!

  26. Shad

    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

      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.

  27. Keith Davis

    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.

  28. Connor Crosby

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

    • Editorial Staff

      They are using something similar. WordPress.org showcase is using this plugin :)

      Admin

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.