[ Content | View menu ]

Rate My Stuff: A Plugin for WordPress

Rate My Stuff allows you to create attractive, customizable, star-based rating images on your site like this:

****

The above image was created with the following syntax: [rate 4]

Why?

Because I’ve started to review some of the books I read and some of the movies that Reneé and I watch, I wanted to have a graphical rating system, and I didn’t want to manually insert all the images every time. Basically, I’m lazy. :)
I had written a private plugin to do this that required the PHP Exec plugin; it just made a function available for me to call it from the post. But I’d been wanting to play with WordPress’ “real” plugin capabilities for a bit to flex my tiny PHP muscles, and this seemed like a good first shot.

Besides, I didn’t see any plugins like this advertised, so I figured I may as well throw my hat in the ring. Maybe someone else will find a good use for it. I guess it’s a small way of giving back to the people I’ve gotten so much from over the years.

Installation

Installing is ridiculously easy:

  1. Download the ZIP file and dump the contents into your plugins folder. A subfolder will be created to hold the stock rating icons that come with the plugin.
  2. Activate the appropriate plugin in your Plugin Management screen.
  3. Use the appropriate rating method depending on your chosen plugin, detailed below.

Which Plugin Do I Use?

As you can see in the code, there are actually two separate plugin files in your plugins folder: rate-my-stuff.php and rate-my-stuff-custom-field.php. The first file is the “classic” version that was released as version 1.0, and the second is the new super-cool version I put together for Chris to accomodate his needs. This means you now can create ratings in two different ways:

  • Using the tag syntax (described below) in the body of your actual post.
  • Using a custom field when you create the post in WordPress.

So the choice of plugin depends on how you want to handle ratings. Using the custom field has the bonus that the data is stored as metadata in the database, and you can query on it as an attribute of the post rather than having to parse the actual post content, but you also have to modify all template files where you want the rating to appear to use the new template tag. Using the tag syntax in the post, while not being properly geeky, is sufficiently simple that you can slap the rating anywhere you like and it will just work. I use the tag syntax on this site, but that’s only because I’m not 100% sure how I’ll handle reviews in the future, and once that shakes out I’ll probably migrate to using the custom field.

And for those who truly can’t make a decision, yes, you can use both plugins simultaneously.

Using the Custom Field

Activate the plugin file Rate My Stuff - Custom Field Variant in your Plugin Management screen. The plugin comes pre-configured to use a custom field called rating (not sure if this is case-sensitive or not) that will take any value, but I highly recommend you stick to a number from 1 to 5. :)
Also, in order to actually display the rating, you will need to modify every template file where you want the rating to be shown. Add the following code to display the rating:

<?php show_post_rating($post->ID); ?>

By default the plugin will output the rating wrapped in a div with a class of rating, ready for your mad CSS skillz.

Using the Tag Syntax

Activate the plugin file Rate My Stuff in your Plugin Management screen. You can now use the sugary-sweet tag syntax in your post/page content as many times as you see fit.

The tag syntax is brain-dead simple:

  1. an opening square bracket
  2. the word “rate”
  3. a space
  4. a number from 1-5
  5. optionally, a decimal followed by the number 5 to denote a half-rating
  6. a closing square bracket

Here are the tags you can use “out of the box”:

[rate 0]
[rate 0.5] ½
[rate 1] *
[rate 1.5] *½
[rate 2] **
[rate 2.5] **½
[rate 3] ***
[rate 3.5] ***½
[rate 4] ****
[rate 4.5] ****½
[rate 5] *****

Like I said, brain-dead simple. You can see a few examples of it in use on this site.

Gotchas

Just one. If you rate something has having only 0.5 stars, you must write it as 0.5 and not as .5. This is because of how the code is written, and because I’m lazy. And oh yeah, I prefer being explicit. But if you just have to have it, write up an alternative and I might implement it.

Oh, and don’t forget to modify your template files if you are using the Custom Field Variant.

Customizing

There are two main ways to customize the script as it comes “out of the box” so to speak: changing the images used, and changing the maximum number of icons displayed. You would do the latter if you wanted to use a 10-star scale rather than just five, for instance.

Changing the images is, again, brain-dead simple. Just change the three deceptively named images in the rate-my-stuff folder. These images should be named rating_star.solid.gif, rating_star.half.gif, and rating_star.empty.gif. Completely defying years of web design commandments, the script does not output image height and width in any way, so you can make them as large or small as you like without having to change the script at all. However, it now outputs appropriate alt attributes for each image.

If you want to change the maximum number of images used in the rating, or change the alt text for the images (because you’re anal that way) then you want to work in the core.php file located in the rate-my-stuff folder. You’ll see the variables inside the config block, and it should all be self-explanatory. Just change them to whatever you like.

The code itself has some ugly warts to it, but hey, it Works For Me™! :)

Questions? Suggestions?

Please direct all feedback to this post.

Change Log

  • 1.1 - Split into “classic” and “custom field variant” plugins
  • 1.0 - Initial release

19 Comments

Write comment - TrackBack - RSS Comments

  1. Pingback from Test af rating » M-ALO’s Monologer:
    [...] 15:05 Dette er blot et testindlæg for at teste om rating-funktionen virker (til brug for mine anmeldelser af bl.a. koncerter). Jeg har brugt et plugin lavet af Dave Cantrell, ved navn Rate My Stuff Mike Harding, ved navn DS-Rating, som jeg har modificeret en lille smule så det passer til mit behov. [...]
    April 13, 2006 @ 6:56 am
  2. Pingback from » Test af rating M-ALO’s Monologer: Om alt og intet, og hvad derimellem hører!:
    [...] Dette er blot et testindlæg for at teste om rating-funktionen virker (til brug for mine anmeldelser af bl.a. koncerter). Jeg har brugt et plugin lavet af Dave Cantrell, ved navn Rate My Stuff Mike Harding, ved navn DS-Rating, som jeg har modificeret en lille smule så det passer til mit behov. [...]
    November 3, 2006 @ 6:32 pm
  3. Pingback from Chrismise.blog » Blog » Dica de plugins:
    [...] Rate my Stuff de Dave Cantrell Insira facilmente avalia
    July 28, 2007 @ 2:04 pm
  4. Pingback from WordPress Plug-in List for Meandering Passage, Aug. 2007 : Meandering Passage:
    [...] lets you tracker your visitors in near realtime using an RSS reader software. – Plug-in: Rate-My-Stuff Version: 1.1 Author: Dave Cantrell Desc:  Lets you use a dynamic, star-based rating system in your [...]
    August 10, 2007 @ 3:03 pm
  5. Pingback from My Thoughts » New plugin Installed:
    [...] Rate My Stuff Plugin [...]
    August 22, 2007 @ 9:36 pm
  6. Pingback from Site Design V - Plugins:
    [...] Rate My Stuff Useful little plugin that allows you to choose to display ratings in your post. Especially helpful if you’re into reviewing books and movies. See it in action in my movie review of The Fountain. [...]
    September 9, 2007 @ 10:58 am
  7. Pingback from Essential Plugins for your Blog - Part2 (Posts):
    [...] Rate My Stuff Useful little plugin that allows you to display ratings in your post. Especially helpful if you’re into reviewing books, movies, products, and other stuff. See it in action in my movie review of the film masterpiece, The Fountain. [...]
    September 11, 2007 @ 12:33 pm
  8. Pingback from At the movies — Allen Lew’s Thoughts:
    [...] movies he’s watched. I’m attempting to add something similiar to this site, using the Rate My Stuff plugin. Two movies are listed below. I’m still tweaking and perfecting this [...]
    November 17, 2007 @ 6:31 pm
  9. Pingback from How to Use a Poll to Find Out What Your Readers Want:
    [...] Rate My Stuff is a WordPress plugin that, well, lets you rate your stuff. It shows a nice 5 star rating, but, it’s meant for people giving their own opinion about stuff. Like your own personal review of a movie or book. Nice stars, but we’re looking for something that will let visitors rate our posts, giving us feedback.  [...]
    December 8, 2007 @ 10:48 pm
  10. Pingback from Upgraded to Wordpress 2.3.2 @ Sparkle Sparkle [Shoujo and Josei Fandom Blog]:
    [...] Ratings page myself that displayed the post results for each possible star rating generated by the Rate My Stuff Custom Field plugin, but I wasn’t sure if it would become useless in the [...]
    January 2, 2008 @ 12:01 am
  11. Pingback from How to Use a Poll to Find Out What Your Readers Want | WebDiggin.com: An Adventure to Make Money Online:
    [...] Rate My Stuff is a WordPress plugin that, well, lets you rate your stuff. It shows a nice 5 star rating, but, it’s meant for people giving their own opinion about stuff. Like your own personal review of a movie or book. Nice stars, but we’re looking for something that will let visitors rate our posts, giving us feedback. [...]
    February 23, 2008 @ 2:07 am
  12. Pingback from Scott O’Raw’s Journal » Comments Re-Visited:
    [...] viewers to rate the post (for those of using self-hosted Wordpress installations there are rating plugins available). I stopped using Pownce several months ago as I felt that I simply didn’t have [...]
    February 24, 2008 @ 2:02 pm
  13. Pingback from Test af rating:
    [...] for mine anmeldelser af bl.a. koncerter). Jeg har brugt et plugin lavet af Dave Cantrell, ved navn Rate My Stuff Mike Harding, ved navn DS-Rating, som jeg har modificeret en lille smule så det passer til mit [...]
    April 12, 2008 @ 4:17 pm
  14. Comment by Nina:

    I just love your plugin and I’ve just installed it at my blog. Thanks a lot for it! Anyway, I have a suggestion: since a lot of people have different paths to wordpress core files and the blog itself, you should change (inside core.php) the get_bloginfo(’url’) to get_bloginfo(’wpurl’) and it’d work for everyone :)

    Thanks!
    Nina

    June 23, 2008 @ 9:50 am
  15. Comment by Alexandre:

    Hello,

    I am using an “asides” plugin in my blog (MiniPosts2 by Morgan Doocy and e) and I’d like to display the rating stars within them, in the sidebar.

    Is this possible? I don’t know much about programming, but I believe the sidebar is considered to be “outside the loop”, right?

    I’d really appreciate any help. Thanks!

    August 15, 2008 @ 9:35 am
  16. Comment by mugger:

    WP 2.6.1
    RATE MY STUFF: put all *.php in folder, uploaded to plugins,
    activated one version, see no settings, nothing to use. Same with other version.

    October 31, 2008 @ 1:11 pm
  17. Comment by Don:

    Got it to work once, only. Now just see “[rate 5]“.

    October 31, 2008 @ 3:23 pm
  18. Comment by My Monster Has A Name:

    Hello DeadCan’tRant,

    Thank you so much for this plug-in. It works perfectly, and my programmer friend has had luck customizing it as well. I do wish it had a transparent background already though, then it would really be slick out of the box!

    Thank you again!

    My Monster Has A Name

    May 5, 2009 @ 4:27 am
  19. Comment by dots...:

    hi , i am not so good with css .. that is why i choose the second option. I have uploaded the file in the plugin directory and activated it. But then i didn’t know what to do next. When i add the code u have written up in the blog post i am writing i get it as it is published i.e. [rate 0] . I don’t know if i am supposed to add an extra coding to it can u please bare with me and explain it to me what shall i do to have it
    thank u

    May 16, 2009 @ 8:10 pm
Write comment

Comment spam protected by SpamBam