Support

Account

Home Forums Feature Requests Convert PHP register_field_group array to JSON Reply To: Convert PHP register_field_group array to JSON

  • @hube2: I often used to define the fields for a site in PHP, with the old register_field_group function. There are many sites that I built like that which I have updated to ACF5.

    As I’m sure you know, the JSON save/sync features of ACF5 are much better. Ideally, ACF would read that file and output a bunch of JSON files in the appropriate place.

    In the meantime, I did a quick and dirty little php file, similar to @morgan’s suggestion. If anyone wants to use it, just paste the contents of a field group into the $array variable, then set the $themePath to the absolute path to your theme.

    You have to do this separately for each field group, so it can be slightly laborious if you have many of them. I tried (for 5 minutes) to parse the entire file, but I couldn’t figure out the regex for extracting each array, so I did it the quick and dirty way.