Hey there,
I have an update_sub_field
inside a foreach after which, I do a get_field
of the repeater right after the update, but it still has the old values even though the update_sub_field
did indeed update everything correctly.
Not sure why ACF get_field
is still getting old values. Thanks for any help!
E.g.
$lists = get_field('lists', $post->ID); // repeater field
foreach ($lists as $key => $list) {
update_sub_field(array('lists', $key, 'field'), 0, $post->ID); // switch from '1' to '0'
}
$lists = get_field('lists', $post->ID);
var_dump($lists);
// outputs old values which is incorrect
Help, Hilfe, Upomoc! 🙂
I did manage to find a temp. workaround for this issue by setting $list[ $key ]['field'] = 0
within the foreach
and then updating the repeater i.e. update_field('lists', $lists, $post->ID)
before retrieving it again. Not exactly an optimal solution though.