Hacking GD Star Ratings for WordPress: inserting ratings in your theme
This is a continuation from a previous post that looks at custom development based on the GD Star Ratings plugin for WordPress.
You would think this would be the most highly documented feature – how to actually insert the ratings for a particular article right in your theme. Heck, maybe there’s a way to do it from the Admin panel that I haven’t even noticed, but I’m a back end kinda guy anyway. Here’s the full code. This one has been written to work within The Loop, but it’s trivial to modify it to work with a custom loop or query if you wanted:
$postRatingData = wp_gdsr_rating_article(get_the_ID()); gdsr_render_stars_custom(array( "max_value" => gdsr_settings_get('stars'), "size" => 12, "vote" => $postRatingData->rating ));
That’s basically it in a nutshell. Max Value is the “total” number of stars (eg: 5 out of 5), Size must be one of the default sizes ie: 12, 16, 20, 24 etc, Vote is the actual calculated result, which we got by passing the ID of the current post to wp_gdsr_rating_article.