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)
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β.
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.
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.
1 | <?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.
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.
1 | <?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.