Using A Default Rating With WP-PostRatings Plugin
Posted on January 7, 2009
Stumble it!
|
Email This Post
|
Print This Post
|
Part of the Wonderful WordPress Wednesdays Series - Previous in series Next in series
Welcome to the eleventh installment of my Wonderful WordPress Wednesday series.
Today’s lesson is a quick little hack for one of my favorite plugins: WP-PostRatings (by the irrepressible Lester ‘GaMerZ’ Chan) which adds an AJAX rating system for your WordPress blog’s posts. I don’t use it here on Philaahzophy, but it’s a vital part of several other blogs that I manage.
My problem occurred on my amusement park and roller coaster video blog where I also use a plugin (that I previously wrote about) to schedule posts for future dates. You see, I’ve noticed that people are far more likely to actually rate a post if others have already done so. Therefore I was visiting each post after it was published and rating it myself. This can become bothersome since I schedule posts on that blog days or even weeks in advance. What I needed was for the WP-PostRatings plugin to add a default rating score to every post as it was published. Luckily, with a little poking around and some help from more PHP-knowledgeable friends I was able to come up with a solution.
Simply navigate to Plugins > Editor > WP-PostRatings in your WordPress admin area and scroll down to lines 763-766 which read as follows:
add_post_meta($post_ID, 'ratings_users', 0, true);
add_post_meta($post_ID, 'ratings_score', 0, true);
add_post_meta($post_ID, 'ratings_average', 0, true);
Now, change the values in each variable to reflect your default ratings. For example, to have each post be published with a single rating and a score of 4 you would change the code to appear as follows-
add_post_meta($post_ID, 'ratings_users', 1, true);
add_post_meta($post_ID, 'ratings_score', 4, true);
add_post_meta($post_ID, 'ratings_average', 4, true);
You can set whatever default ratings you like, but make sure that your math works out or you’re likely to get some type of error.
ratings_usersrefers to the number of different people that have entered their ratingratings_scoreis the total value of all the ratings thus far added togetherratings_averageis the current score of the post
So you’ll want to make sure that ratings_score divided by ratings_users is equal to ratings_average. If you’re worried about the math, just use the values in the example above and all of your posts will publish with a rating of 4 granted by a single user (you do think all of your posts are worthy of at least 4 out of 5 stars, don’t you?).
As always, if you have any difficulty with this tip, questions about using WordPress more effectively, suggestions for future articles in this series, or just want to say ‘Hi’ or ‘Thanks’, comments are always very much appreciated! And if you found this post useful or informative, please consider adding it to your choice social bookmarking sites (StumbleUpon, Digg, Reddit, etc).
Part of the Wonderful WordPress Wednesdays Series - Previous in series Next in series
The Complete Wonderful WordPress Wednesdays Series-
- Introducing Wonderful WordPress Wednesdays!
- Lighten The Load Of Your WordPress Blog – Part One
- Lighten The Load Of Your WordPress Blog – Part Two
- Starting A Blog? Install These 5 WordPress Plugins First!
- Popularity Protection For Your WordPress Blog
- Can Your WordPress Blog See The Future? Mine Can!
- Moving Your WordPress Blog To A New Web Server In 10 Easy Steps
- Pretty Blog Pictures Thanks To CSS!
- Falling In Love All Over Again – WordPress 2.7
- Stop Letting Sponsors Determine Your Blog Layout!
- Importing Large MySQL Databases With BigDump
- Using A Default Rating With WP-PostRatings Plugin
- Victory Over The Comment Spammers
Related Posts: » Filed Under: Blogging, Wonderful WordPress Wednesdays
» Trackback to: Using A Default Rating With WP-PostRatings Plugin


that is great
nfl jerseyss last blog post..Buffalo Bills Donte Whitner White Replica Football Jersey #20
[...] amazing WP-PostRatings plugin to allow visitors to rate your posts, then you’ll probably find Using A Default Rating With WP-PostRatings Plugin, posted at Philaahzophy very [...]
Is there a way to locate someone locally to try this?
Good post!Listed in My Favourite Now!And I couldn’t wait to share my wonderful tiffany co shopping experience.I have bought a tiffany bracelet at the price I never imaged.