Home › Forums › General Issues › Json on child theme › Reply To: Json on child theme
I’ve found a way to do it using the code here: https://gist.github.com/joelstransky/053d18846d3e42631aec773e4346e2ca
1. In child theme Load ACF field groups from parent:
// Load ACF Fields from Parent Theme
add_filter('acf/settings/load_json', 'parent_theme_field_groups');
function parent_theme_field_groups($paths) {
$path = get_template_directory().'/acf-json';
$paths[] = $path;
return $paths;
}
2. In parent theme get child theme ACF JSON variants to overwrite parent theme:
add_filter('acf/settings/save_json', function() {
return get_stylesheet_directory() . '/acf-json';
});
add_filter('acf/settings/load_json', function($paths) {
// $paths will already include the result of get_stylesheet_directory ie. parent theme's acf-json
if(is_child_theme()) {
$paths[] = get_template_directory() . '/acf-json';
}
return $paths;
});
3. Create /acf-json/ folder in child theme. Copy required ACF field group files from parent to child (only ones that will need customising). Sync these files in your child theme ACF Field Groups list.
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.