Introducing Post rating: another rating plugin for wordpress

Yes I know, there are plenty of rating plugins for WordPress already. I’ve tried most of them and never really found one I truly liked. Recently though I ran across the Rate plugin by Scott Taylor, a fresh approach to rating posts by letting visitors leave a rating after commenting.

I found myself liking Rate quite a lot, but for some sites you want to shop Aviva Polo rate the post yourself, and so I was inspired to write my own rating plugin, that was just as clean and unobtrusive as Rate. Nothing fancy, nothing big and clumsy, and not a complete solution to all your rating related needs, but a small package that you can use as a base in your projects.

To use Post rating you need to be able to edit your theme’s templates, and perhaps write some widgets of your own. The plugin allows you to easily rate any given post on a user-defined scale. It can display the rating as text or using stars, and also lets you query for the top rated posts.

There isn’t much style from the start, but the css that exists is easily overridable.

To display a posts rating:

post_rating( "stars" );

The only argument decides how to output the rating, as stars or text.

To include the top rated posts in a loop:

global $post_rating;
$args = array(
  'posts_per_page' => 10
);

$top_rated = $post_rating->top_rated( $args );

while( $top_rated->have_posts() ) : $top_rated->the_post();
  echo "<h2>{$post->post_title}</h2>";
endwhile;

wp_reset_postdata();

You can modify the query any way you like, just check out the wordpress codex for query_posts.

The code currently resides at github.
Feel free to fork!

This entry was posted in Web development and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>