Home › Forums › Backend Issues (wp-admin) › acf-json files not being created
Hello,
I am creating acf-json
as per the documentation here. ACF is not creating any JSON files as I create Field Groups. I am not seeing any errors.
I am running the latest ACF Pro 5.9.4 on a Multisite install however I intend for all my subsites to use the same theme. My permissions are set to 755. I am able to upload media and install plugins via the CMS interface so no issues there either as far as I can tell.
I have tried deactivating and reactivating the plugin as well as completely removing it (via the CMS Plugins) and reinstalling it but no change unfortunately.
Does anyone know of any complicating factors around trying to install on a Multisite (but wanting to use the same theme across all subsites)?
Any help much appreciated!
If you’ve created the acf-json folder in the theme folder then is should be working unless there is a write permission problem.
If you are using a child theme then that acf-json folder must be in the child theme folder. If you want the acf-json folder to be in the parent theme then what you need to do is have one site that uses the parent theme where you make changes while all other sites use the child theme and in the child theme you add a json load point to load groups from the parent theme.
Thanks @hube2 but I’m not using child themes, just one theme that all Multisite Subsites will use.
Regarding permissions, AFAIK everything is set correctly. 755 on the directory. I’m not having any other permission based issues with file uploads, plugin installs etc. File owner/group is www-data:1000
which is just fine for everything else.
I’m stumped!
I’m stumped as well. Not knowing what could cause this I would start outputting debugging information by following the code in ACF and and making changes.
For example the ftil /includes/local-json.php line ~205 the function save_json, the following are some of the things I would do. Please note that only one of these would work at a time and would prevent the saving.
public function save_file( $key, $field_group ) {
$path = acf_get_setting( 'save_json' );
// see what the path is
echo $path; die;
$file = untrailingslashit( $path ) . '/' . $key . '.json';
if( !is_writable($path) ) {
// folder not writable
echo 'path is not writable'; die;
return false;
}
// Append modified time.
if( $field_group['ID'] ) {
$field_group['modified'] = get_post_modified_time( 'U', true, $field_group['ID'] );
} else {
$field_group['modified'] = strtotime();
}
// Prepare for export.
$field_group = acf_prepare_field_group_for_export( $field_group );
// see what the field group looks like
echo '<pre>'; print_r($field_group); die;
// Save and return true if bytes were written.
$result = file_put_contents( $file, acf_json_encode( $field_group ) );
// see what is returned by file_put_contents()
echo '<pre>'; var_dump($result); die;
return is_int( $result );
}
Depending on my debugging here I would move to either on to other functions, either those called by this function or I’d look for where this function is called.
Thanks @hube2 I’ll find some time to try that in the next couple of days (I’ve run out of time this weekend!) Appreciate your help so far and I’ll report back.
When I run into things that make me scratch my head I just go back to basic debugging. There has to be a reason it’s not saving.
@hube2 Fixed! I followed your debugging steps. I found that, because I’m also using Timber, the path wp-content/themes/my-theme/acf-json
wasn’t sufficient and that I actually need wp-content/themes/my-theme/theme/acf-json
as the path. That didn’t take me very long at all so thank you!
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.