Skip to content

Instantly share code, notes, and snippets.

@theMikeD
Last active September 16, 2022 10:46
Show Gist options
  • Save theMikeD/b66840caefdcf8f34100 to your computer and use it in GitHub Desktop.
Save theMikeD/b66840caefdcf8f34100 to your computer and use it in GitHub Desktop.
Changes the folder where ACF loads and saves the JSON file to and from
<?php
add_filter('acf/settings/save_json', 'cnmd_set_acf_json_save_folder');
add_filter('acf/settings/load_json', 'cnmd_add_acf_json_load_folder');
/**
* Set a new location to save ACF field group JSON
*
* @param string $path
* @return string
*/
function cnmd_set_acf_json_save_folder( $path ) {
// update path
// CHANGE THIS
$path = CNMD_CF_DIR . '/acf';
// return
return $path;
}
/**
* Adds a folder to the ACF JSON load list
*
* @param array $paths
* @return array
*/
function cnmd_add_acf_json_load_folder( $paths ) {
// Remove original path (optional)
unset($paths[0]);
// append path
// CHANGE THIS
$paths[] = $path = CNMD_CF_DIR . '/acf';
// return
return $paths;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment