Skip to content

Instantly share code, notes, and snippets.

@timothyjensen timothyjensen/functions.php Secret
Created Oct 31, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.