Skip Navigation

[Closed] how to get rating average from cred review parent child

This support ticket is created 8 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Africa/Cairo (GMT+02:00)

This topic contains 1 reply, has 2 voices.

Last updated by Ahmed Hussein 8 years ago.

Assisted by: Ahmed Hussein.

Author
Posts
#394825

I found a great post:
https://toolset.com/forums/topic/how-to-get-rating-average-from-cred-for-review/page/3/

this was exactly what I needet. works like a charm.
but post is closed and I don't get any answer or feedback so I extendet my queation to here.

my problem:

on a restaurant/venue page I have child posts with ratings and I can display the total average rating. PERFECT.

I have a facebook like startpage, displaying new venue posts, with total rating.
this works fine.

than I also display new commtes/ratings for venues.
I can display the users rating, but not the total rating.
becaus the post is already the child.

I tryed

1
[rating-average id="$venue"]
but I know this can't work. it was just a good portion of hope ?

how can I make it work ?

this is my function:

add_shortcode('rating-average', 'rating_average_func');
function rating_average_func()
{
    $child_posts = types_child_posts('venue-rating');
      
    $sum = 0;
    $num = 0;
    foreach ($child_posts as $child_post) {
        if(isset($child_post->fields['rating-venue']))
        {
            $sum += $child_post->fields['rating-venue'];
            $num ++;
        }
    }
    $res = '';
    if($num>0)
    {
        $res_10 = $sum/$num;
    }
    $res = $res_10/10;
    return $res;
};

(don't worry about /10 .. I user for rating 10,20,30,40,50 istead of 1,2,3,4,5)

I hope you guys understand what I mean.
maybe for better help:

hidden link

so if someone can help me to figure out how to display the total average of the parent.. that would be so AWESOME ?

thank you all
max

#395014

Hi, Thanks for contacting Toolset support forums.

I would like to get more details about your current setup, your post types relationships with each other, and what type of fields (text, radio, select, etc) is set for the Rating field. And also, if possible provide some links that show how the rating currently works, and how you wanted to work.

The information will help me give you the proper solution.

Cheers!

The topic ‘[Closed] how to get rating average from cred review parent child’ is closed to new replies.