Skip to content

Instantly share code, notes, and snippets.

@yratof
Last active September 16, 2022 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yratof/f9192e20d7c4851cf979 to your computer and use it in GitHub Desktop.
Save yratof/f9192e20d7c4851cf979 to your computer and use it in GitHub Desktop.
acf load json files and sync
<?php
function acf_fields() {
// Load field files dynamically
$field_files = glob( dirname(__FILE__) .'/acf-fields/*.json' );
foreach ( $field_files as $file ) {
if ( apply_filters( 'midsona_allow_acf_file', true, $file ) ) {
$json = json_decode( file_get_contents( $file ), true );
$json[0]['local'] = 'json';
// $json[] =
acf_add_local_field_group( $json[0] );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment