Noscope is a bi-weekly journal serving up snacksized portions of pointless stuff since 2001.
I also do freelance design and usability via dejligt.com

Ratings Short-tags Plugin for Wordpress

    14:52 on February 20th, 2009 , ,

If you review books and movies, you’ll want to provide a rating. Usual movie ratings consist of 1-5 or 1-6 stars, zero stars reserved mainly for Uwe Boll movies.

This plugin let’s you do just that. Simply write

[rating=5]

and you’ll get this:

There’s an options page which allows you to configure the rating symbol (another popular one is the ★), the symbol color, the empty symbol color and lastly how many stars you can give away at the most.

Download

Download Ratings Shorttags

Syntax

The following shorttags (or shortcodes) are available:

[rating=5]
[rating stars="5" /]

Other Notes

Questions have been asked why the default option outputs 6-star ratings. First of all, this is an option you can change if you prefer 5 star ratings (or even 3 or 20 star ratings). The reason for 6 being default is that this requires the reviewer to decide whether a movie is mediocre-good (4 stars) or mediocre-bad (3 stars). This is more useful than a 3/5 rating, because that’s the exact middle.

Replacing The Symbols With Images

Ratings Short-tags already supports using images instead of unicode symbols to show ratings. You just need to use a little CSS to get it going. Here’s an example:

.rating span { /* both full and empty symbols */
	display: block;
	width: 20px;
	height: 20px;
	float: left;
	text-indent: -9999px;
	background: url('url/to/fullstar.gif') no-repeat left top;
}
.rating span.empty { /* overwrite empty symbols image value */
	background: url('url/to/emptystar.gif') no-repeat left top;
}
.rating:after {
	content: ".";
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
	zoom: 1;     /* triggers hasLayout */
}

45 Comments

  1. animealam tweeted this.

Pings

  1. Ratings Shorttags : Un système de notation de vos articles | Geekeries.fr - Astuces Wordpress 2.7, Plugins Wordpress 2.7, Blogging, Référencement, Actualités High Tech
  2. Wordpress Ratings and Review Plugins | Wordpress Directory
  3. Karakter fra 1-6 stjerner i blogs « IT & udviklingsbloggen

Comments

  1. Johan says:

    Nice! I’ll definitely try it out. :)

  2. Augusto says:

    cool plug-in Joen!

    what about an option (tag) to list all review’s on a page?

  3. Joen says:

    This plugin has been updated to not show “empty” stars in feed viewers. The “empty” is done using CSS, which obviously doesn’t translate to feeds, so…

  4. Steve (subscribed) says:

    In the above paragraph you explain that there is an options page to alter the symbol. Where is said options page?

  5. Steve (subscribed) says:

    No, could be that I am using a newer version of Wordpress?

    • Joen says:

      No, this should work with versions 2.5 to 2.8. I’m using 2.7.1.

      Try redownloading and reactivating the plugin.

      Do the shortcodes work? Does anything appear if you write [rating stars="5"] ?

  6. Steve (subscribed) says:

    The shortcodes do work, I will try reactivating it.

  7. Steve (subscribed) says:

    Okay, I reactivated it and it’s now there, still a bit unsure as to how that allows me to change the image. I will mess with it for now, thanks a ton for the help!

  8. Steve (subscribed) says:

    lol, ya I guess I should have noticed that from the start. What I mean is there a place to find a compiled list of unicodes? I am looking for (I know this sounds silly) a spoon.

  9. Steve (subscribed) says:

    Awesome!

    Thank you, you’ve been more than helpful. Very impressed with how fast you replied to all my questions and I really like this plug-in.

  10. Brian (subscribed) says:

    I cant seem to get the images working, after i placed the CSS code in the stylesheets do I need to make any changes to the settings of the plugin?

  11. Aaron Storm says:

    Is there a way to show the ratings on the post title; especially on the main page?

    • Joen says:

      As such, the intention of the plugin so far has only been to provide the shortcodes ([rating stars="x"]). Shortcodes only work in the body of your posts.

      However, there’s been some interest in a small rewrite which would feature the ability to list, for instance, all 5 star reviews. That would mean storing the rating in the database somewhere. If I had the rating stored there, there’s no reason I couldn’t output it in the title, as an option.

      So yes, it’s possible.

      One important thing, however, this is just speculation and I’m truly and honestly too busy to work on this for the next foreseeable future. If, however, someone takes interest in this plugin and would like to take it upon themselves to build it in soon, I’d love to give SVN access (it’s all open source here).

  12. santin (subscribed) says:

    Love this!! very helpful!!

    but is there any way to remove HTML code “p”?

    I mean… I only need the “span” tag, like this

    http://www.flickr.com/photos/santinaki/3500800427/

    and I use this plugin here

    http://san-tin.com/iphone/2009/05/big-diary-and-notes/

    sorry for my poor English…

    • Joen says:

      Yes, you can remove the extra P tag. You just have to edit the plugin, and remove wpautop from line 48 in the ratings-shorttags.php file. Note, it says wpautop($something) and you should remove the wpautop( and ), but not the variable in between.

    • santin (subscribed) says:

      It works.

      Thank you very much!

      _

  13. boilr says:

    thanks for this great plugin!

    is there any way to show fractions/parts of a symbol?

    i.e. If I rate a movie 4.5 stars out of 5, is there a way to do that with this plugin?

    also, is there a way to enlarge the symbol output size?

    thanks

    • Joen says:

      boilr: is there any way to show fractions/parts of a symbol?

      i.e. If I rate a movie 4.5 stars out of 5, is there a way to do that with this plugin?

      No, I’m afraid not. But you could set the maximum stars to 10, and show 9/10 stars. But I don’t think that’s what you’re after.

      boilr: also, is there a way to enlarge the symbol output size?

      Yes, using CSS:

      .rating {
      font-size: 16pt;
      }
  14. boilr says:

    thanks for your prompt reply. i might just have to switch to a 10 star rating since this plugin is so useful.

    on a random note, i’m having a tough time updating my comments page (my theme is really old and has been modified piecemeal for a few WP releases now) for 2.7 nesting, etc…any chance you could share (via email or wherever) your comments code (comments.php and accompanying css)? its very clean and well done.

    thanks again

  15. boilr says:

    noob question. any idea how i can get the rating symbol to align vertically with my preceding text?

    here’s an example of usage – http://www.boilr.net/2009/06/06/update-linksys-wrt54g2-router-works-like-a-champ/

    thanks again for the great plugin and prompt support

  16. Nice plugin. I’m trying it out already.

    Shorttags do work fine, but unfortunately my co-bloggers are not that IT-savvy and not very much into anything that looks like just the tiniest bit of code. They could really use something wysiwyg.

    Is there any chance that you could make at button in the TinyMCE toolbar, which makes it easy to insert the rating/the shorttag?

    For example, see Vipers Video Quicktags for reference/inspiration. I know it’s a more complicated plugin but Viper007Bond managed to do something like that.

    Anyway, thanks for a nice plugin. Keep up the good work.

  17. Frank says:

    The code for images should be like this

    .rating span { /* both full and empty symbols */
    	float: left;
    	display: block;
    	width: 20px;
    	height: 20px;
    	text-indent: -9999px;
    	background: url('/wp-content/stars/star.png') no-repeat left top;
    }
    .rating span.empty { /* overwrite empty symbols image value */
    	background: url('/wp-content/stars/emptystar.png') no-repeat left top;
    }

    you need the “float: left;” to have your stars from left to right ;)

    • Joen says:

      Oh, right, good point. Then you probably also need a clearfix, like this:

      .rating:after {
      	content: ".";
      	display: block;
      	height: 0;
      	clear: both;
      	visibility: hidden;
      	zoom: 1;     /* triggers hasLayout */
      }
  18. EZ says:

    Hi there! Great plugin, I love it.
    I saw you mentioned this only works in the BODY of a post, but how would I be able to get it to work using custom fields, so I could automatically insert numbers into it? Could I place it in a template tag somewhere or modify an existing template to show after a post? Please email me if this is too complicated.
    Thanks!

Leave a Reply

Have something to say? Jump right in!

(required)
(required)