WP Customer Reviews
Inserting Average Review on another Page (7 posts)

  1. kaylamatthews
    Posted 3 years ago #

    Following this thread:


    I was able to create the average score on the post/page where the review is enabled.

    I am currently using the shortcode [WPCR_SHOW] to show the rating on another page, however am having a really hard time showing the average rating on that page.

    I know the modifications need to be made inside the

    function output_reviews_show()

    function inside wp-customer-reviews.php but am not sure how to do it. I have used the same code as found in the above thread but the average review is always ZERO since it's capturing the aggregate review for the page where the shortcode is embedded.

    Let's look at the code in the thread above that is pulling the average rating for the post where the review form is embedded:

    The function:

    function get_average_rating() {
             global $post;
             $average_score = number_format($this->got_aggregate["aggregate"], 1);
            return $average_score * 20; // 20% for each star if having 5 stars

    HTML rendering:

    $average_rating = 'Average Rating: <div class="sp_rating"><div class="base"><div class="average" style="width:'.$this->get_average_rating().'%"></div></div></div>';

    Inserting average rating into the template:

    $the_content .= $average_rating;

    The issue I believe is the ($post->ID) array inside the average_rating function as it's telling the average_rating function to grab the aggregate value for the page the shortcode is embedded on. I have tried so many things I don't know where to begin to post here, I am not a PHP expert unfortunately.

    Rending the HTML and calling it in the template via

    $reviews_content = $average_rating; inside the

    function output_reviews_show section

    is straightforward but I do not know how to make it so the average rating in this case is based on the postid the [WPCR_SHOW] shortcode indicated.

    Does anybody have any ideas? I believe this question was asked many times and if we can solve it this time it will help a lot of people!


  2. kaylamatthews
    Posted 3 years ago #

    Some updates - i got the average rating to show on another page now, but only the first one works and the rest of the average ratings for DIFFERENT posts are all showing the same average rating result as the first one...

    I simply moved the "HTML rendering"

    $average_rating = 'Average Rating: <div class="sp_rating"><div class="base"><div class="average" style="width:'.$this->get_average_rating().'%"></div></div></div>';

    and "Inserting average rating into the template" codes

    $the_content .= $average_rating;

    Except now this becomes

    $reviews_content .= $average_rating;

    from above into the

    function output_reviews_show()


    I should be really close to getting it, I think the issue lies in the

    function get_average_rating()

    function, the line


    the $post->ID is the culprit?

  3. dreddie27
    Posted 3 years ago #

    sorry i'm a newb so cant help. But did make a small donation to the developers in the hope it will keep them interested and help solve your problem. (after wich i can use it also :-)

  4. kaylamatthews
    Posted 3 years ago #

    Can anybody please help? I have hired a dev but he is unable to produce any results after 2 days...

  5. successwill
    Posted 3 years ago #

    Seems that its been 3 months but if you have found the solution, please tell me.

    i want to pull a hundred overall rating into a table which is on a separate "page".

    And i want to let the users to sort the table according to some criterias such as rating, year, new..etc..

    Any help.?

  6. kartguru
    Posted 3 years ago #


    I'd like to know if you eventually solved your issue and how (if you don't mind sharing)?


  7. kartguru
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Customer Reviews
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic