Support

Account

Home Forums General Issues Save a Variable in a Custom Field

Helping

Save a Variable in a Custom Field

  • 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.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Save a Variable in a Custom Field’ is closed to new replies.