I inserted the following code to show average review rating on my page:
$pId = 9; //if using in another page, use the ID of the post/page you want to show ratings for.
$row = $wpdb->get_results(“SELECT COUNT(*) AS
max_ratingFROM wp_wpcreviews WHERE
page_id= $pId AND
$max_rating = $row->max_rating;
$aggregate_rating = $row->aggregate_rating;
$total_reviews = $row->total;
$totl = $aggregate_rating * 20;
echo “Average: ” . $aggregate_rating . ” stars for ” . $total_reviews . ” reviews!”;
Is there a way to show only 2 decimal places instead of the default 4?
- The topic ‘Overall rating’ is closed to new replies.