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?
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/
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).
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 🙂
You must be logged in to reply to this topic.
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.