Home › Forums › ACF PRO › Is it possible to have local JSON files in both theme and plugin folders › Reply To: Is it possible to have local JSON files in both theme and plugin folders
I’ve managed to get it working using your code as a starting point. This is my first try at anything plugin related so there might be a better/cleaner way to do it, or things I haven’t considered.
I have 2 ACF field groups
/********************************/
// Save and load plugin specific ACF field groups via the /acf-json folder.
/********************************/
// Save
function my_plugin_update_field_group($group) {
// list of field groups that should be saved to my-plugin/acf-json
$groups = array('group_5d921d2978e9e');
if (in_array($group['key'], $groups)) {
add_filter('acf/settings/save_json', function() {
return dirname(__FILE__) . '/acf-json';
});
}
}
add_action('acf/update_field_group', 'my_plugin_update_field_group', 1, 1);
// Load - includes the /acf-json folder in this plugin to the places to look for ACF Local JSON files
add_filter('acf/settings/load_json', function($paths) {
$paths[] = dirname(__FILE__) . '/acf-json';
return $paths;
});
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 use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.