Home › Forums › General Issues › Automate Updating Fields Across Hundreds of Sites
I’m working on a network of wordpress installations that were cloned from a base copy. That means that all the custom field groups are the same across each site. I would like to update/add/otherwise edit these field groups, but I’m having trouble automating this.
For example, I’d like to create a new field group and assign it to a specific page. The only way I know how to do across all sites would be to export the new fields and then to log in and manually import them on all 200 sites.
Does anyone have any suggestions on how best to automate this? I’ve looked into a scripting + wp-cli solution but I can’t figure out a way to import fields from the command line. The sites to not have acf-json enabled.
Are they all using the same theme? https://www.advancedcustomfields.com/resources/local-json/
Yes, all the sites use the same theme.
Is there a way to automate that syncing process?
While fooling around with this local JSON feature yesterday I noticed that the field groups don’t update until you run the Sync action from within the admin area. Is there a way to sync field groups programmatically, for example from the command line?
No, there isn’t a way automatically sync them, but there really isn’t any need to sync them unless you are working on the field on a specific site. the JSON files override the DB everywhere but when editing the group. So, if you are going to edit a group you sync it, otherwise there’s no reason to do so.
This is super promising. I didn’t realize I could define new field groups solely by providing a different JSON file. This most likely will solve my problem.
Generally when I do this on multisite I have one master site where I edit all field groups. I make sure that I have downloaded all of the field groups after any changes.
Usually, I just activate the theme on new sites, the existence of the json files means that the field groups will be active on the new site without importing them.
In some cases I create new sites by duplicating an existing site. In this case I go into the admin of the new site and delete all of the field groups from ACF. This has an unintended site effect of deleting the json files. But then I just upload them to the theme. If I do this I generally do it when I’m sure no one will be active.
Another option is to disable the ACF admin on all but the master site where I make any changes. https://www.advancedcustomfields.com/resources/how-to-hide-acf-menu-from-clients/
This was great .. I was so much satisfied that my work became so quick and easy due to its new grea features.
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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.