Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Last active October 8, 2019 17:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vanaf1979/c5cc6a5c102b1279be3e2f7efec5dc8c to your computer and use it in GitHub Desktop.
<?php
function load_acf_json( string $file ) : array {
return json_decode( file_get_contents( get_template_directory() . $file ) , true );
}
function register_acf_field_group() : void {
$fieldgroups = load_acf_json( '/acf-field-groups/test-field-group.json' );
foreach( $fieldgroups as $fieldgroup ) {
acf_add_local_field_group( $fieldgroup );
}
}
add_action( "acf/init" , "register_acf_field_group" );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment