ACF won't load from a custom JSON location

I’m trying to set up local json sync with ACF on a multisite installation. It worked with the default acf-json folder in the child theme, but I’d like to save and load everything from the parent theme. I managed to make it work when it comes to saving (custom fields will get saved to the parent theme folder from all subsites). However, the filter for loading (acf/settings/load_json) doesn’t seem to trigger. Even when I just try to output some strings in the error log.

I’m not sure what I’m doing wrong since I basically just copy pasted the documentation’s code and only changed the path, but the fields won’t sync.

Any help would be appreciated! Thank you

Here’s what I put in functions.php:

// changes saving location for custom fields
add_filter('acf/settings/save_json', 'my_acf_json_save_point');
function my_acf_json_save_point($path) {
    // update path
    $path = get_template_directory() . '/custom-fields';
    
    // return
    return $path;
}

// changes loading location for custom fields
add_filter('acf/settings/load_json', 'my_acf_json_load_point');
function my_acf_json_load_point( $paths ) {
    error_log('hey!');
    
    // remove original path (optional)
    unset($paths[0]);
    
    // append path
    $paths[] = get_template_directory() . '/custom-fields';
    
    // return
    return $paths;
}

Topic advanced-custom-fields sync multisite custom-field Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.