I have WordPress site and the plugin Advanced Custom Fields, I have created a custom post for testimonials, inside is custom field called 'ratings' where you in put a number e.g. 1, 3.5, 5 etc.
I want to take all the number from the field for each post and add them up to a total or average out of 5.
However I'm struggling I can get it to populate the ratings e.g. 5, 5
But I can't get them to add up, can any one help please?
This is what I have below so far...
<?php
$args = array( 'post_type' => 'testimonial', 'posts_per_page' => 9999 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<?php
$count = (get_field('rating'));
print_r($count);
$add = count($count);
return $add;
echo $add;
?>
<?php
endwhile;
?>