Support

Account

Home Forums Feature Requests Import PHP for further use in UI tool Reply To: Import PHP for further use in UI tool

  • 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.