WordPress.org

Ready to get started?Download WordPress

Forums

WP Customer Reviews
Overall rating (1 post)

  1. Vatravel
    Member
    Posted 1 year ago #

    I inserted the following code to show average review rating on my page:

    global $wpdb;
    $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 total,AVG(review_rating) AS aggregate_rating,MAX(review_rating) AS max_rating FROM wp_wpcreviews WHERE page_id= $pId AND status=1");
    $max_rating = $row[0]->max_rating;
    $aggregate_rating = $row[0]->aggregate_rating;
    $total_reviews = $row[0]->total;
    $totl = $aggregate_rating * 20;
    $wpdb->flush();
    echo "Average: " . $aggregate_rating . " stars for " . $total_reviews . " reviews!";

    Is there a way to show only 2 decimal places instead of the default 4?

    http://wordpress.org/extend/plugins/wp-customer-reviews/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.