Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schutzsmith/225df0d79bd0bbad308463f41877c851 to your computer and use it in GitHub Desktop.
Save schutzsmith/225df0d79bd0bbad308463f41877c851 to your computer and use it in GitHub Desktop.
Convert an ACF Field Group from PHP to ACF-JSON
<?php
// 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