Viewing 15 replies - 1 through 15 (of 17 total)
  • Did you get an answer on this? I would like to do the same thing

    Thread Starter Gunny

    (@nobsstudios)

    No. I did not.

    I have since decided to go in a slightly different direction and will not be using this plugin.

    @cbarnhart : are you still interested in this ?
    @gunny : what do you use now ? Thank you

    Thread Starter Gunny

    (@nobsstudios)

    zeuf,

    I went with a more robust review plugin that allows me to define multiple criteria for the item to be rated against, as well as the traditional star rating. I can add my own rating and criteria and I can also allow site visitors to do the same.

    There are three plugins, and one is now free (I believe) and should be enough to meet most requirements. You can view them all here:

    https://authorhreview.com/plugins

    Thank you Gunny.
    I decided to improve the PHP code of this one.

    What have you done to improve the code? Have you added a way to display the average rating/stars accrued for a post or page?

    Plugin Author Aaron Queen

    (@bompus)

    The new version of WP Customer Reviews (3.x) changes the review format from hReview to microdata which Google prefers and it also allows for less issues with themes and other plugins. It also adds the aggregate review for each page/post which solves a few problems all at once.

    Look for the beta of it soon. You can sign up for the beta from the plugin page on the gowebsolutions website.

    Hi Cbarnhart,
    Do you still want my “poor” lines of PHP ?
    Thank you so much Bompus ! Great plugin !

    I can wait for the release, but thank you for the offer

    Does anyone actually did the average function ? I’m working in that solution in a project but i wanna know if there is something already out there

    @zeuf I’d appreciate if you can post your code. Thanks in advance!

    I would love this as well!
    Thanks in advance to whoever comes up with a solution to this! ??

    I came up with a solution. It may not be the best but it works. Any improvements are welcomed.

    Add this to single.php inside the loop


    global $wpdb;
    $pid = get_the_ID();

    $review_query = "SELECT r.page_id rid, AVG(r.review_rating) average_rating, COUNT(*) total_reviews
    FROM {$wpdb->prefix}wpcreviews r, $wpdb->posts p
    WHERE p.ID = r.page_id
    AND p.post_type = 'post'
    AND p.post_status = 'publish'
    GROUP BY r.page_id";

    $get_reviews = $wpdb->get_results($review_query, OBJECT);

    if ($get_reviews) {
    foreach ($get_reviews as $review) {
    if ($review->rid == $pid) {
    $average_rating = number_format($review->average_rating, 1);
    $total_reviews = $review->total_reviews;
    }
    }
    }

    if ($average_rating && $total_reviews) {
    echo 'Average: ' . $average_rating;
    echo 'Total reviews: ' . $total_reviews;
    }

    I agree we do need a shortcode to add under [WPCR_INSERT] to allow the option above or below the review area, to show a ‘total’ overall star rating. ‘COMPANY-X has a 3.5/5 star rating out of 1xx reviewes!’ – Post a review.

    @lahiru Hi. What would your average rating / aggregate rating code look like for static pages / page.php ? (rather than post.php)

    Thanks or your efforts.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Average rating/stars for the page/post?’ is closed to new replies.