Support

Account

Home Forums ACF PRO ACF PRO programmatically import fields

Solved

ACF PRO programmatically import fields

  • Hi,

    I’ve found myself really wanting to start using ACF PRO on our new projects but there is one critical drawback for me – not being able to programmatically import the custom fields.

    I currently do this using the XML export feature of ACF4, and then use some custom code to import this on a fresh install, which works great. I need to be able to do the same thing with the new JSON files, to speed up setup time.

    I did try searching for this, finding a couple of old threads which didn’t offer a solution. Is there a way to do this, or will there be shortly?

    In the meantime, can I call an import function in ACF PRO from my theme, providing a string or file path for the file to import, to achieve the same effect?

  • Hi @alancolyer,

    New to ACF Pro is the JSON Sync(added in v5.1.5) feature that allows which detects changes to local JSON files and allows the user to update the corresponding field groups within the Database. This functionality is visible when viewing the field group admin page but only when ACF has detected there are field groups available for synchronizing.

    You can also opt to do the importation of the fields using the PHP export facility that allows you to copy the export code to your theme files.

    Calling an import function is not available at this time.

    Please check out the resource page on the JSON sync feature here http://www.advancedcustomfields.com/resources/synchronized-json/

  • Hi James,
    thanks for replying to this thread – in the meantime I had adopted ACF PRO but was just manually importing a JSON file for each new site.

    Being able to sync these is something I didn’t know about, thanks for the link – just tried it out and it worked great. I think I can live with it now 🙂

  • What if I want to sync the changes programmatically?

    From what I understand, currently, automated deployment is not 100% possible.

    'private' : true doesn’t seem to apply to Local Json (as the json is auto-generated and manual changes don’t stick).

  • Hi @mariowhat-digital

    If you want to update the fields programmatically, you need to add the 'private' : true option to the field group. But please keep in mind that this will hide the field group on the backend, so you won’t be able to edit it from the field group editor page.

    If you find the same field group on the backend, it mostly a duplicate that has its own JSON file.

    I hope this makes sense 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘ACF PRO programmatically import fields’ is closed to new replies.