Home › Forums › General Issues › update_field() not working in loop › Reply To: update_field() not working in loop
Have you tried to print get_field('field_5b303fe622a15')
? Maybe it’s a subfield ?
I’ve tested this code on a WP loop and it worked :
$count = (int) get_field('count');
if ( $count >= 0) {
$count++;
update_field('count', $count);
}
By the way, get_field and update_field can be used with the field’s name instead of the field’s key.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.