Last active
November 11, 2021 04:38
-
-
Save mishterk/d3b8ced5dad3f8b0f57f5b2a2173bf05 to your computer and use it in GitHub Desktop.
These snippets accompany the article: https://www.awesomeacf.com/forcing-acf-field-group-json-file-generation-for-all-field-groups/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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!'; | |
} ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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