Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelstransky/053d18846d3e42631aec773e4346e2ca to your computer and use it in GitHub Desktop.
Save joelstransky/053d18846d3e42631aec773e4346e2ca to your computer and use it in GitHub Desktop.
Advanced Custom Fields acf-json support for child themes
<?php
/**
* Child theme support for acf-json
* This will load acf-json from the parent theme first.
* That way if a child theme's acf-json folder contains a .json
* file with the same name as the parent, it will get loaded second
*/
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;
});
@nickberens360
Copy link

@joeltransky Greetings, do you put this in the child functions.php or the parents?

@aaronsummers
Copy link

aaronsummers commented Jun 25, 2020

@joeltransky Greetings, do you put this in the child functions.php or the parents?

This goes into your parent theme. Very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment