Hi.
I have some custom fields in my posts that I use to make some additions and I save the results in some variables. I would like to save those variables in custom fields to show them elsewhere.
This is part of the code, for a better understanding:
<?php
$total = 0;
while(the_repeater_field(‘polizas’ )):
$total += intval( get_sub_field(‘monto’ ) );
endwhile;
$count = 0;
$polizas = get_field(‘polizas’);
if (is_array($polizas)) {
$count = count($polizas);
}
echo “<table>”;
echo “<tr>”;
echo ” <th>Total$</th>”;
echo ” <th>Faltan$</th>”;
echo ” <th>Total#</th>”;
echo ” <th>Faltan#</th>”;
echo “</tr>”;
echo “<tr>”;
echo “<td>$total</td>”;
$faltan=300000-$total;
echo “<td>$faltan</td>”;
echo “<td>$count</td>”;
$faltancount=30-$count;
echo “<td>$faltancount</td>”;
echo “</tr>”;
echo “</table>”;
?>
You can update field values with update_field.