Skip to content

Instantly share code, notes, and snippets.

@timothyjensen
Created October 31, 2017 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothyjensen/b20040fd28130672c734527338081286 to your computer and use it in GitHub Desktop.
Save timothyjensen/b20040fd28130672c734527338081286 to your computer and use it in GitHub Desktop.
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