ACF get json by name.
<?php | |
/** | |
* Returns the ACF JSON filename by group name. | |
* | |
* @param string $field_group_name Name of the ACF field group | |
* @return string|bool | |
*/ | |
function get_acf_json_by_name( string $field_group_name ) { | |
$field_group_lookup = [ | |
'hero' => 'group_59e226a200966.json', | |
'cta' => 'group_59e226a200967.json', | |
// Add more field_group_name => file_name pairs here. | |
]; | |
if ( ! isset( $field_group_lookup[ $field_group_name ] ) ) { | |
return false; | |
} | |
return $field_group_lookup[ $field_group_name ]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment