Last active
September 20, 2017 23:43
-
-
Save craigpearson/c25ce40c1a97fbbfae0d452a4555a93f to your computer and use it in GitHub Desktop.
Update ACF JSON load / save path in Sage 9 starter theme. Drop into app/filters.php or include from functions.php
This file contains hidden or 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
/** | |
* Update save location for ACF JSON | |
*/ | |
add_filter('acf/settings/save_json', function ( $path ) { | |
// Add path - Note uses get_template_directory to override any child theme JSON | |
$path = get_template_directory() . '/assets/acf-json'; | |
// Create the directory in themes that don't exist | |
if (!is_dir($path)) { | |
mkdir($path); | |
} | |
return $path; | |
}); | |
/** | |
* Update load location for ACF JSON | |
*/ | |
add_filter('acf/settings/load_json', function ( $paths ) { | |
// Remove orginal path | |
unset( $paths[0] ); | |
// Add path - Note uses get_template_directory to override any child theme JSON | |
$paths[] = get_template_directory() . '/assets/acf-json'; | |
return $paths; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment