Perfect. I guess that’s job done then.
Many thanks for your help.
Exactly what I needed. Many thanks.
Do you know if the results of acf_get_field_groups or acf_get_fields are automatically cached in any way or do they always result in a separate db call?
Updated version of my code if it’s useful to anyone:
public static function field_defined($name, $post_id='') {
if(!$post_id){
if (!$post_id = get_the_ID()){throw new Exception("$id must be supplied if called outside of loop");}
}
$groups = acf_get_field_groups(array('post_id' => $post_id));
foreach($groups as $group){
foreach(acf_get_fields($group['key']) as $field){
if($field['name'] == $name){return true;}
}
}
return false;
}