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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.