Support

Account

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.