Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
/*add before get_aggregate_reviews($pageID) */
function get_average_rating() {
global $post;
$average_score = number_format($this->got_aggregate["aggregate"], 1);
return $average_score * 20; // 20% for each star if having 5 stars
/*do_the_content($original_content), just after $the_content = ''; add the following:*/
// build average ratings html
$average_rating = 'Average Rating: <div class="sp_rating"><div class="base"><div class="average" style="width:'.$this->get_average_rating().'%"></div></div></div>';
/*add after $the_content .= '<div id="wpcr_respond_1">'; /* start the div */*/
// attach average ratings to beginning of reviews
$the_content .= $average_rating;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment