There is nothing built into ACF that will let you import php code. You need to manually get the field group, convert it to JSON and then save it to a file.
// create field group in php $group = acf_get_field_group('group_key'); $group['fields'] = acf_get_fields('group_key'); $json = json_encode($group); // save the json to a file http://php.net/manual/en/function.file-put-contents.php // there are other ways to do this as well
When I’m converting a field group to PHP I generally also export a JSON version so that if I need to I can import it to make changes.
The only reason I use PHP is if I want to make everything available for translation or I am going to do things that the ACF UI is incapable of doing, like building a dynamic field group that changes based on the page that’s being edited. If I am not worried about any of these conditions then I export the group as JSON and I add a load point to make ACF load the JSON files.
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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 29, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.