Skip to content

Instantly share code, notes, and snippets.

@craigpearson
Last active September 20, 2017 23:43
Show Gist options
  • Save craigpearson/c25ce40c1a97fbbfae0d452a4555a93f to your computer and use it in GitHub Desktop.
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
/**
* 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