Support

Account

Home Forums General Issues Get all fields with a certain setting Reply To: Get all fields with a certain setting

  • This would be the only way to do it. Even if you wanted to get just one setting for a field ACF still needs to get the entire field definition. ACF needs to do this anyway for each field to know what type of field it is and other information so that it knows what to do with the value. This is why the dev gave us local JSON files for the group to cut down on DB queries. You getting the field object is not causing any extra work than is already being done.

    If this is something you need to do a lot then you could create your own function

    
    function my_acf_get_field_setting($field_name, $setting, $post_id=false) {
      $value = NULL;
      if (!$post_id) {
        $post_id = get_the_ID();
      }
      $object = get_field_object($field_name, $post_id) {
      if ($object && is_array($object) && isset($object[$setting])) {
        $value = $object[$setting'];
      }
      return $value;
    }
    

    then in your template

    
    $setting = my_acf_get_field_setting($field, 'special');