Home › Forums › General Issues › ACF-JSON Custom Folder Location Not Working
I’m able to create the default /acf-json in the child theme and everything works. But I have a series of sites where we cannot use the child theme approach, so I’m trying to define a custom folder in
/wp-content/uploads/acf-json
My code is
function my_acf_cpt_save_folder( $path ) {
return ABSPATH . 'wp-content/uploads/acf-json';
}
add_filter( 'acf/json/save_paths/type=acf-post-type', my_acf_cpt_save_folder );
I’ve tried variations of get_home_url and other variations of preceding and trailing slashes.
I’ve confirmed permissions are correct (as they are with it working with the child theme version)
I’m wondering… does the acf-json folder have to be within the theme somewhere, or can it exist anywhere. Or is there something else I’m doing wrong.
This is a new feature in ACF and according to the documentation it is supposed to work. I can only guess there is a bug. You should report it to the developers. They posted a link to this https://www.advancedcustomfields.com/feedback/ in the blog about this release. I would try that, or contact the developers or create a ticket in your account.
Thanks @hube2 I saw that post but wasn’t sure it was related or not… guess so. This is my first time working with JSON so wasn’t sure. I’ll submit a ticket.
According to the documentation what you have should be working if I’m understanding it correctly.
Hey @blakemiller,
You’re mixing up filters here. save_paths doesn’t support a type argument, as it’s for filtering the whole array, although we do pass you in the post as an argument so you can detect if it you like:
apply_filters( 'acf/json/save_paths', $paths, $post );
Alternatively, you can use the save_path (no s) setting with a type argument, so something like:
add_filter( 'acf/settings/save_json/type=acf-post-type', 'set_custom_json_save_path_for_post_types' );
function set_custom_json_save_path_for_post_types() {
return get_stylesheet_directory() . '/acf-json/post-types';
}
We have to keep both around for backwards compatibility, so sorry it’s a bit confusing!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.