Support

Account

Home Forums ACF PRO Get next field value in foreach loop through field group Reply To: Get next field value in foreach loop through field group

  • 
    $show_next = false;
    foreach ($fields as $field) {
      
      if ($field['type'] == 'true_false' && $values[$field['name']]) {
        // this is a true false field set to true
        $show_next = true;
      } elseif ($field['type'] == 'true_false' && !$values[$field['name']]) {
        // this is a true false field set to false
        $show_next = false;
      } elseif ($show_next) {
        // the field is not a true false field
        // but the last true false field was true
        // output field
      }
    }