Star Rating for Reviews
Star Rating for Reviews is a simple WordPress plugin that inserts pretty rating stars based on the score you assign using intuitive, inline [rating:] tags. It can also calculate and output overall ratings for you based on all previous scores you have assigned, useful for reviews that have multiple categories or an album review where each track is assigned a score.
This plugin supports storing rating data into your WordPress database. These data can then be retrieved by functions provided to output a list of reviews, sortable by date, post title or rating scores. Random reviews function and single post function (to be used in WordPress loop) are also provided, see Usage section for detailed description of these functions.
Features
- uses simple, intuitive tags to generate kawaii inline rating stars for your posts
- supports versatile rating systems
- supports text only output for RSS
- automatically calculates and displays overall ratings, if desired
- supports storing rating scores automatically into database *
- supports outputting list of reviews sortable by date, post title or rating scores *
- supports widget-like, sortable table of reviews *
- supports custom star images
- supports custom prefixes and suffixes for your own CSS class
- supports globally forced star count for consistency
- uses as many stars as you want! **
- standards compliant: valid XHTML
* database writing has to be enabled via Options
** limited to 20 for practicality
Usage
Presentation
Data (for advanced users)
Presentation
Once installed, you can add rating stars to your posts by using [rating:] tags.





By default, this will be interpreted as 3.5/5, as shown in the rating stars generated. Default denominator can be changed via options detailed in the next section. Even though this tagging style is simple, it might not be future proof when someday you decided to change the default denominator to say 10 (for whatever reason). In this case 3.5 will be interpreted as 3.5/10, which is very different compared to 3.5/5. Once you start using this tagging style, make sure you are not going to change the default denominator in the future. :)




“3/4″ will generate a “3 out of 4 stars” rating and “2/8″ will generate “2 out of 8 stars” and so on. This will continue to work as long as the denominator is not larger than 20. Beyond that, the score will be normalized and display in the default 5 stars system, as shown in the next example.





The “Rating:” prefix you can see in all examples above is the default prefix, which you can remove easily to show just the stars or add in your own custom CSS class by changing some options. More information about this in the Options section.
Overall rating:
Automatically calculated overall rating based on previous scores can be inserted using the following tag style:





Similar to the first example, this overall rating will be represented in the default 5 star rating system. It is possible to force the overall rating to be outputted in different number of stars by using the following tag style:




The “Overall Rating:” is again, the default prefix, which can be changed via options. For more information, see Options.
Custom images:
First of all, the default star image used is taken from the excellent Silk icon set. These png icons support different background colours via png transparency. However, you can still use your own star images by replacing the 3 images included in the “star-rating” plugin folder, namely “star.png”, “halfstar.png” and “blankstar.png”. File extensions can be changed via options if desired.
For your information, “tiny-star.png”, “tiny-halfstar.png” and “tiny-blankstar.png” are only used by special functions that output list of reviews based on stored data in the database. Feel free to replace them with your own images as well if desired.
Text only output:
By default, this plugin will output text only ratings for your RSS feeds and use graphical output when someone is reading the post on your site. This is, in my opinion, the optimal choice since some RSS readers do not support images. However, if you like you can output images for your RSS feeds too, or oppositely, output text only ratings for both RSS and posts displayed on your site. Please refer to the Options section if you want to make these changes.
Data (for advanced users)
Database writing is turned off by default. In order to use these advanced features, you will need to manually turn it on by changing the option values, see Options for more details. If you are not interested in this feature, you should skip this section.
Custom fields
If database writing is turned on, this plugin will parse your document searching for rating tags and store the overall rating score into a custom field called “rating” when you edit or save your blog post. The name of the custom field can be changed via options to prevent conflict with other plugins. The reason why custom field is used instead of a new database table is the ease of implementation and the fact that most people write reviews occasionally. The downside of this is when uninstalling this plugin, you will need to manually remove those “rating” entries within the custom field table.
To check if this plugin is doing its job, once you turned on the database writing, go to edit one of your older posts which already used the rating tags (or simply insert the rating tags into any post if you’re new to this plugin) and choose “Save and Continue Editing”. Now, check the custom field near the bottom of the editing panel to see if a new “rating” field has been added. If it’s there, congrats, this plugin is working properly; if it’s not, you might have forgotten to turn on the database writing option, or the rating tag is invalid. Feel free to post your questions here (with detailed explanation) if you can’t get this to work.
Once you turned on this auto insert feature, you can still disable it for specific post by putting [rating:none] anywhere in your blog post, preferably at the bottom for tidyness.
Functions
4 different functions are provided in this plugin that allow you to output a list of reviews based on date, rating score, or randomly selected. These functions uses “rating” custom field data to retrieve and sort the reviews. You need to either turn on autometa (see Options) or manually put these rating in yourself.
1. sr_getreviews()
sr_getreviews($limit, $orderby, $order, $usestar, $prefix, $suffix)
$limit
- number of reviews to be returned
Acceptable value: any integer
Default value: 5
$orderby
- criterion used to sort the review
Acceptable value: “date”, “title”, “rating”
Default value: date
$order
- sort ascendingly or descendingly
Acceptable value: “ASC”, “DESC”
Default value: “DESC”
$usestar
- number of star to be used for rating
Acceptable value: any integer
Default value: 5
Note 1: put in “0″ to output rating in percentage i.e. numerically
Note 2: rating stars used are with tiny prefix (tiny-star.png, tiny-blankstar.png etc.), they are smaller than regular stars in blog post
$prefix
- prefix to be put before the code for each reviews
Acceptable value: any valid XHTML tags or plain text
Default value: “<li>”
$suffix
- suffix to be put after the code for each reviews
Acceptable value: any valid XHTML tags or plain text
Default value: “</li>”
<?php sr_getreviews(5,date,DESC,5); ?>
You can also output ratings in percentage format as illustrated below:
<?php sr_getreviews(5,date,DESC,0); ?>
2. sr_getrandom()
sr_getrandom($limit, $usestar, $prefix, $suffix)
See the explanation above for each parameter.
<?php sr_getrandom(5,5); ?>
3. sr_listreviews()
sr_listreviews($orderby, $order, $usestar, $date, $limit)
This outputs list of reviews in a widget-like, sortable table format. (implemented using the awesome tablesorter plugin for jQuery)
$date
- format of date to be used
Acceptable value: PHP date format
Default value: “M j, Y”
$limit
- number of reviews to be returned
Acceptable value: any integer
Default value: “0″
Note: “0″ limit implies no limit i.e. retrieve all available reviews
<?php sr_listreviews(date,DESC,5,"M j, Y",10); ?>
| Date | Title | Rating |
|---|---|---|
| Tips: Shift+Click to sort multiple columnsPowered by Star Rating for Reviews | ||
| 2011-06-07 Jun 7, 2011 | AKB48 – Koko ni Ita Koto | 70.8 ![]() ![]() ![]() ![]() ![]() |
| 2010-08-31 Aug 31, 2010 | Garuneku’s Debut Single | 70 ![]() ![]() ![]() ![]() ![]() |
| 2009-09-13 Sep 13, 2009 | Utada – This Is The One | 30 ![]() ![]() ![]() ![]() ![]() |
| 2009-04-30 Apr 30, 2009 | Kuroki Meisa debuts Hellcat | 71.3 ![]() ![]() ![]() ![]() ![]() |
| 2009-03-25 Mar 25, 2009 | Perfume – One Room Disco | 70 ![]() ![]() ![]() ![]() ![]() |
| 2009-02-02 Feb 2, 2009 | Hinouchi Emi – ME… | 75.3 ![]() ![]() ![]() ![]() ![]() |
| 2009-01-31 Jan 31, 2009 | Nishino Kana – MAKE UP | 85 ![]() ![]() ![]() ![]() ![]() |
| 2009-01-12 Jan 12, 2009 | Perfume – Dream Fighter | 95 ![]() ![]() ![]() ![]() ![]() |
| 2009-01-07 Jan 7, 2009 | Proposal Daisakusen | 90 ![]() ![]() ![]() ![]() ![]() |
| 2009-01-05 Jan 5, 2009 | Arashi – truth/Kaze no Mukou e | 93.3 ![]() ![]() ![]() ![]() ![]() |
4. sr_getsingle()
sr_getsingle($post_id, $usestar, $prefix, $suffix, $size)
This function is intended to be used within the WordPress Loop. You can put this within the loop to display rating score or stars in categories, tags, or main page for each posting. See examples: categories, tags, main page.
$post_id
- the ID of current post within the loop
Acceptable value: $post->ID
$prefix, $suffix
- prefix, suffix to be added before and after the ratings code returned
Acceptable value: any valid XHTML tags or plain text
Default value: ” (empty)
$size
- the size of stars, can be normal or tiny
Acceptable value: 0, 1 (0 for tiny stars, 1 for normal stars)
Default value: 0
For $usestar, see the sr_getreviews().
Customization
Starting from version 0.4, a default CSS is imported into the WordPress header, which I hope will work nicely with your blog theme. If not, feel free to open the CSS and edit it or disable the CSS import by setting $sr_mycss to 1, which will remove all the default styling for CSS classes associated with this plugin.
By default, ratings and reviews returned by listing functions are hardcoded with special CSS classes, namely “sr-review” for the review permalink and “sr-rating” for the ratings returned, which can be either numerical percentage or star images.
You might want to take a look at another plugin I’ve written called “MyCSS”, which allows you to attach and edit custom stylesheet that’s independent of the blog theme you’re using. This makes it convenient and easy to organize theme independent CSS classes such as those used in plugins, saving you the trouble of appending these classes into your theme’s core CSS everytime you change a theme.
Options
Hopefully this plugin will work as desired in an “out of the box” way so that you don’t need to change anything. However, several extra options are still provided for those of you who would like to have it your way. :)
Since this plugin is still in its early stage, setting options in the WordPress admin panel is not supported yet. For now, you will need to open up the php file using either your favourite text editor or WordPress built-in plugin editor to change some of the variables you can find near the top of the code.
$sr_limitstar: globally set star count, e.g. putting 5 will ALWAYS generate your score using the 5 star rating system, put 0 to disable this feature$sr_defaultstar: default denominator when not explicitly specified in your tags$sr_prefix: custom prefix for normal ratings$sr_allprefix: custom prefix for overall ratings$sr_suffix: custom suffix, leave blank unless you want to close html tags$sr_ext: file extensions for custom star images, e.g. gif, jpg, png$sr_usetext: text only output settings, accepted values are 0, 1 and 20: images for posts and feeds
1: images for posts, text for feeds
2: text for all$sr_mycss: using your own CSS? if yes, put in 1 to disable default CSS import$sr_cuttitle: shorten post title to specific amount of character, put 0 to disable title cut off
The following are advanced options, mainly to turn on the functionality of storing ratings into database as custom field values:
$sr_autometa: 0 to turn off database writing, 1 to turn it on, this feature is disabled by default (it’s stable, I’m just leaving the choice up to advanced users)$sr_metakey: meta key for custom field, change this if there’s conflict with other plugins
Installation
- Download and extract the “star-rating-for-reviews” folder
- Upload the “star-rating-for-reviews” folder to your WordPress plugin directory, usually “wp-content/plugins”
- Activate the plugin in your WordPress admin panel
Upgrade
- Deactivate the plugin in your WordPress admin panel
- Remove the “star-rating-for-reviews” folder in your WordPress plugin directory
- Follow the installation guide above
Download
Star Rating for Reviews plugin 0.4 for WordPress (30kb .zip)
| Please donate to support active development of this plugin, thank you! |
If you like this plugin, express your love by donating and sharing this plugin with your readers!
Support
If you have any questions, suggestions, or found any bugs in this plugin, feel free to post them in your comments. I’ll try my best to answer them but there’s no guarantee, so don’t be disappointed if you do not hear back from me promptly. :/ If you find this plugin useful and feel like donating some money for my effort, please use the PayPal button above, thanks! <3
History
0.4 [2007.11.02]
- Added: Sort reviews by title
- Added: sr_listreviews() function to output all reviews in a sortable table (good for dedicated review page)
- Added: Default CSS stylesheet (can be turned off via options)
- Added: Cut off long title when getting list of reviews for sidebar
- Changed: XHTML markup for list of reviews generated
- Changed: Tiny star images
- Fixed: Division by zero if overall tag is placed at the top of a post
- Misc: Cleaned up the code and fixed minor bugs
0.3.1 [2006.09.12]
- Fixed: Sorting bugs
0.3 [2006.08.08]
- Added: Support to store rating data into database
- Added: Functions to output list of reviews, sortable by date or by rating scores
- Added: Filter to parse excerpt
- Added: Skip tag parsing by using ` character (suggested by Denis)
0.2 [2006.07.28]
- Fixed: Path error
- Fixed: [strong] instead of [b] for W3C standards
- Fixed: RSS text output bug
0.1 [2006.07.08]
- Initial release





{ 119 trackbacks }
{ 312 comments… read them below or add one }
← Previous Comments
I like the plugin – I think it will work great with my site. Cheers!
Having an issue seeing the text form or image form of the rating using the Atahualpa theme
And do you know How to rate a comment in blogger
here is the full tutorial http://blog.makemycreative.in
nice plugin, thanks
[rating:overall] automatically calculates overall rating based on previous scores. Is there a way to make it calculate overall based on following scores?
I want to be able add overall rating at the top of the post. Is it possible?
Thank you for this great plugin!
hey i am having a lot of trouble with adding rating stars to my sidebar under a banner. The code [rating:5/5] work for post i already tested it but not in the text area of my sidebar how can i add stars to my sidebar? thanks !
hi, can anyone tell me how can I use this plugin with the wp-table reloaded plugin?
i use the [rating:] tag in the table but what I get is the [rating:] tag itself.
thx
Hi.
I have installed the plugin into my site but i don’t understand how this plugin is working. I inserted into a table for voting movies. Why it’s not working when i try to click on the stars to vote?
Great! I was looking for something just like this! Cool for reviews! downloading right now!
This looks like a really nice plugin, i like the interface look better than GDR plugin, thanks for sharing
This is not work on my template :(
Hmm, methinks that with the release of WP 3.0 and custom content types (http://wpengineer.com/impressions-of-custom-post-type/), this plugin might not be needed anymore. No?
The stars aren’t aligned bottom with the “Rating” text.
How can I get this to do this?
would have liked seeing how to put it in the themes template file
Hello,
Love the plug-in!. Only problem is that I am unable to see the stars when in my “Categories” or “Archives”. The Star rating system only appears when on my main page. Is there anyway to fix this?
Hi. After updating your plugin on my website, my “newly added” 5 star reviews now show as 3400% , while the older 5 star reviews still show as 100%… This has messed up the full review list, can you offer any suggestions as to what has gone wrong?
http://ratemybistro.co.uk/full-review-list/
TGreat parsing documents stuff in this plugin!
Very nice plug in! :)
Thats looking strange i did not happen before any time you check your graphic properties and adjust it as the requirement
i just installed your plugin and i am seeing it on my website very clearly. but its speed is too much slow what should i do in this case?
i just installed plugin and i am seeing it on my website
thanks
That’s amazing plugin for rating and I was looking this for my cellphone site and give option to the user to rate phone. and I am going to use this on my number of sites.
Sensational looking web page, where did you obtain the template?
Hi, the stars are too far apart when put on a page. How do I correct this problem ? Thank you.
Project cost: … without the “-”
wondering how to get the star rating properly coded into my portfolio page .. i can get eh shortcode to work but need the PHP code to make it work .. would it be something like this?
Project cost:
really really thanks for this plugin, i am using it on my community blog.It is working fine there.
how to change charts to utf-8?
hi,
I would like to use your plugin on my website about coocking recipies…
I managed to enable the rating on posts.
I yust didn’t manage to make it work in the comments.
Do you know what i have to do (besides enable it in the settings..)
Thanks so much for your answer!!
>Can anyone tell me if this plugin works in wordpress 2.8+?
Sure, and pretty good )
Thanks a lot for that plugin! It look wonderfull on my films blog )
Love the plug, runs great on my page (although I have hidden the stars so it blends with my original post style. I do have one question: How do you actually go about using the functions? Do I just insert “” into the body of a page or what? I have had no luck getting this to display, and – yes – I did change the autometa to 1.
Hey,
Just wondering if there is any way to change the alt tag of the different star rating pictures that are outputted. For example have the alt tag for a 2 star rating be “Nothing Special” and the alt tag for a 5 star rating be “Something to Write Home About!”
Thanks Ki
Thank you sooooo so much for this! Really really helpful!
this is very informative but i need this type of rating on wap so how i do?
i downloaded this and now i am trying to put it under a picture for everyone to rate. how do i do this step by step? i have no idea how to use this.
by the way i am using a facebook pic to rate.
I have very little techie knowledge, so please dumb down your answer for me. : / I’m setting up to redirect my entire site to a new Wordpress review site. With this plugin, how do I add some html code into the text widget to display the ratings? I would like to have some sort of side-widget that displays either recent ratings, or best rated on the sidebar. I read the usage instructions and looks like greek to me, and I don’t even know if this addon has that ability. I appreciate your time.
Hey,
i have a problem with your very helpful plugin:
I can’t see the rating stars if I open the categorys… Is there any possibility to solve this problem?
Ciao Carli
Did you ever figure out how to solve this problem? I’m having the same one and would really like to know how to resolve it…
Can anyone tell me if this plugin works in wordpress 2.8+?
Thanks
it works
If I send you some money, will you upgrade the plugin so that I can choose which category to display a list of reviews? I know you have worked on the plugin in awhile, but this is an oft requested feature. Thanks so much.
-Chris
I’m using WP 2.9.1 and Star Rating 0.4
Using [rating:5] in post works perfectly.
But I tried to use functions : sr_getreviews() or sr_listreviews() in a post, in a page, in sidebar (widget) and it doesn’t work.
Even the function sr_getsingle() in a post doesn’t work.
I turn on $sr_autometa in the php file of course.
What did I forget to do ?
i just installed your plugin but i am not seeing it on my website. any idea why?
FYI, the maximum output is set at 5 stars.
Hello, I’ve been using Star Ratings for Reviews for a while and have come across this weird thing where it displays way too many stars. Even deleting the custom field and reentering does not work either.
Here is what I am trying to show you: http://www.emmafrostfiles.com/archives/comics-review-archive/
if you know what is going on, please let me know. Thanks.
Nevermind. I figured it out! I just added the class to the xhtml output code. Thanks.
I love this plugin and have been using it for over a year. I have a quick question, though. Can I add a class to the image output? I would like the code output to look something like this: . Is that possible?
[rating:3.5]
Thank you so much for your plugin. It helped me so much! Thanks.
Hope you could have more plugins in the future. If you are free, is it possible for you to have a post on how to do the “notify me of followup comments via e-mail”? I find that absolutely convenient.
Yet again, your effort is greatly appreciated.
I have used your plugin and I find it very useful and I do recommend to my blog readers.
I have this error how can i fix this ploblem
Warning: str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0 in /home/fergusga/public_html/wp-content/plugins/star-rating-for-reviews/star-rating.php on line 327
Do you use Twitter Tools? I do, and I’m getting the same error from tweets posted on my blog.
great star rating plugin, Good for wordpress, Tell visistor which artcile is best. hehe
Love your plugin so much. After tried the $99 WPReviewSite and WPReviewEngine, Yours is much much better. Much cleaner. Your plugin should worth $1000! Thanks
← Previous Comments