I am using Advance Custom Fields local json so I can synchronise my forms across different environments.
See my function below, with var dump outputs in comments so you can see what is going on...
function acf_json_absolute_path ($path) {
/**
var_dump($path);
Array (
[0] => /sites/joshmoto/subdomains/domain/wp-content/themes/werks/acf-json
)
*/
$path[0] = get_template_directory() . '/config/acf-json';
/**
var_dump($path);
Array (
[0] => /sites/joshmoto/subdomains/domain/wp-content/themes/werks/config/acf-json
)
*/
return $path;
}
add_filter('acf/settings/save_json', 'acf_json_absolute_path');
add_filter('acf/settings/load_json', 'acf_json_absolute_path');
But every time I save my custom fields, nothing appears in the config/acf-json
folder.
But if I create an empty acf-json
folder in the root of my theme, and re-save all my ACF field groups, json files are created here instead.
I don't understand why config/acf-json
path is getting ignored and using the default acf-json
location?
Can anyone help me understand save/load json to my config
folder location?
I am using Advance Custom Fields local json so I can synchronise my forms across different environments.
See my function below, with var dump outputs in comments so you can see what is going on...
function acf_json_absolute_path ($path) {
/**
var_dump($path);
Array (
[0] => /sites/joshmoto/subdomains/domain/wp-content/themes/werks/acf-json
)
*/
$path[0] = get_template_directory() . '/config/acf-json';
/**
var_dump($path);
Array (
[0] => /sites/joshmoto/subdomains/domain/wp-content/themes/werks/config/acf-json
)
*/
return $path;
}
add_filter('acf/settings/save_json', 'acf_json_absolute_path');
add_filter('acf/settings/load_json', 'acf_json_absolute_path');
But every time I save my custom fields, nothing appears in the config/acf-json
folder.
But if I create an empty acf-json
folder in the root of my theme, and re-save all my ACF field groups, json files are created here instead.
I don't understand why config/acf-json
path is getting ignored and using the default acf-json
location?
Can anyone help me understand save/load json to my config
folder location?
1 Answer
Reset to default 1the two filters don't have the same output. you can test that
add_filter('acf/json_directory', function ($path) {
return get_template_directory() . '/config/acf-json';
});
add_filter('acf/settings/save_json', function ($path) {
return apply_filters("acf/json_directory", NULL);
});
add_filter('acf/settings/load_json', function ($paths) {
return [
apply_filters("acf/json_directory", NULL)
];
});