I have created custom fields for comments with ACF, and I am doing calculation for comments. It works well but for single comment. I would like to calculate all values from specific field for all comments.
$number1 = get_field('number1',$comment) $number2 = get_field('number2',$comment) $number3 = $number1 + $number2
I have this code and it does the calculation for single comment. Now I would like to get values for that fields from all comments for that post, and do the calculation like
$number_total = $all_numbers / $number_of_fields
Is that possible?
$total = $var1+ $var2+ $var3+ $var4+ $var5; $stat= $total /5; } echo $stat; echo '/100';
And the var1,var2,var3 are advanced custom fields
if( have_rows('safety',$comment) ): while ( have_rows('safety',$comment) ) : the_row(); the_sub_field('field1'); $field1= get_sub_field('field1'); $safety_points= $field1; $safety_total= $safety_points/5*100; echo $safety_total; endwhile; else : endif;