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');
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.