Some of my field groups are only relevant to a specific theme, others are used by the 3 themes I have installed.
I’d like to have as single overall ACF setup to manage. I want to be able to switch themes without having to modify the ACF setup. And my client can only see field groups that make sense to his.her theme.
How would you go about putting this together? Custom location rule? PHP registering? JSON? Something else?
They are self-standing themes (however if a client need some customization I would implement that via a child theme).
My aim is to have a core ACF setup that I can tweak if a theme requires it. Right now I have used the admin UI to register the field groups. Ideally ACF would have a native “If current theme is xxxxxxx” location rule.
Eventually the fields will be deployed on the sub-sites of a multisite network which I hope will not add too many constraints (had to start this project somewhere and it wasn’t there).
If I was going to do something like this, starting at the beginning and knowing that I would be moving to a multisite setup……..
I would start by setting up multisite and I would create a “master theme” where I would create all of the field groups. This master theme would have an acf-json folder so that when I made changes to a field group the changes would be saved in the json folder. Without doing this you would need to import the field groups to each them anyway, so you would not have a master location for maintaining all the field groups.
I might actually create the acf-json folder in the root of /themes/ rather than in the theme and then use the custom save and load points in ACF to https://www.advancedcustomfields.com/resources/local-json/
$path = dirname(get_stylesheet_directory()).'/acf-json';
In each of the other themes I built I would create my own function to load the field groups that are needed for each theme from this master theme json folder using a variation of this https://github.com/Hube2/acf-filters-and-functions/blob/master/acf-load-parent-theme-field-groups.php… this was something that I created either before acf allowed multiple load points or before I realized they existed. I keep it around because it’s a good reference. I would only load the groups I needed, filtering by the group key.
My goal would be to limit the number of places that these field groups existed and this would limit it to 1 locations and one place where they could be edited.
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!
We've just released ACF 5.12.3 with a security fix to prevent arbitrary file uploads to forms with ACF fields.— Advanced Custom Fields (@wp_acf) July 14, 2022
Now that we've released this update, we recommend updating your sites as soon as possible.
© 2022 Advanced Custom Fields.