Skip to content

Instantly share code, notes, and snippets.

@furahaclothing
Created March 2, 2014 13:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furahaclothing/9306656 to your computer and use it in GitHub Desktop.
Save furahaclothing/9306656 to your computer and use it in GitHub Desktop.
wp-customer-reviewの平均評価、総評価数
/*add before get_aggregate_reviews($pageID) */
function get_average_rating() {
global $post;
$this->get_aggregate_reviews($post->ID);
$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