Created
March 2, 2014 13:37
-
-
Save furahaclothing/9306656 to your computer and use it in GitHub Desktop.
wp-customer-reviewの平均評価、総評価数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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