Created
May 10, 2017 02:25
-
-
Save joelstransky/053d18846d3e42631aec773e4346e2ca to your computer and use it in GitHub Desktop.
Advanced Custom Fields acf-json support for child themes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
}); |
@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
@joeltransky Greetings, do you put this in the child functions.php or the parents?