Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
add_action( 'admin_post_acf_sync', function () {
$field_groups = acf_get_field_groups();
// Apply our callback to all field groups
array_map( function ( $field_group ) {
// Load up the fields on the field group.
$field_group['fields'] = acf_get_fields( $field_group );
// Write the local JSON file for the field group.
acf_write_json_field_group( $field_group );
}, $field_groups );
echo 'done!';
} );
<?php
$field_groups = acf_get_field_groups();
// Apply our callback to all field groups
array_map( function ( $field_group ) {
// Load up the fields on the field group.
$field_group['fields'] = acf_get_fields( $field_group );
// Write the local JSON file for the field group.
acf_write_json_field_group( $field_group );
}, $field_groups );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment