Skip to content

Instantly share code, notes, and snippets.

Last active July 2, 2023 18:07
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Convert an ACF Field Group from PHP to ACF-JSON
// Get all the local field groups and loop through them for processing.
$field_groups = acf_get_local_field_groups();
foreach ( $field_groups as $group ) {
// If the field group has fields, load them into the 'fields' key.
if ( acf_have_local_fields( $group['key'] ) ) {
$group['fields'] = acf_get_local_fields( $group['key'] );
// Write the group's JSON file.
acf_write_json_field_group( $group );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment