I want rating system like on wordpress's official site.

Every user while making review can rate post (2) and the total rating is displayed near the post (1).

Looks pretty simple but all plugins which I found by now either show only total rating or allow to rate comments of users or to do whatever else but not these.

Any help is appreciated because I got lost in plugins and think of writing by myself this functionality from scratch.

enter image description here

  • Coding this is relatively easy. Add a custom post metavalue with a key value containing the rating of the post which updates when the user votes. Then display this post using the wp_star_rating() function which is in the core. To stop users from voting twice on the same vote, simply store the post ID in the user's custom metadata (in an array) and do a check on that value when you load up the page. This is a lot more simple than it sounds actually. – Christine Cooper Dec 8 '14 at 2:16
  • Good, thanks for clarification! After all I came across this plugin - wordpress.org/plugins/rate . It does exactly what I described. But you explanation is pretty useful, if you post it as answer I would approve it – Tebe Dec 8 '14 at 8:43
  • Sure, please check my answer. – Christine Cooper Dec 8 '14 at 14:58

While there are a lot of plugins that adds rating type of stars, I would suggest that you code your own. Mainly because most of these are very feature rich with things you will not need.

This is a relatively simple process:

  1. Add a custom user metadata using update_user_meta(), name it posts_voted.

  2. Add a custom post meta value using update_post_meta(). The string value will be the rating, for example, 4.5. Name it post_rating.

  3. Then add rating stars to your single.php using wp_star_rating().

  4. When user selects their rating, you should update the user's post_voted value and store the post's ID in the array, and then you should use their choice of rating and add a simple algorithm for the post_rating value.

  5. Finally, on loading the page, do a check if the user's posts_voted contains the ID of the post; if it does, disable the voting for this user.

Doesn't this sound a lot better than adding a random plugin that contains tons of unnecessary features?

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.