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
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!