Support

Account

Home Forums General Issues Load priority local .json files

Helping

Load priority local .json files

  • Hi,

    I’m developing a theme and a plugin by using ACF Pro an the same time.
    When I add a field group the local .json file is created in my theme folder in the acf-json folder.

    I then copy the local .json file to my plugin folder in the acf-json folder.

    When I load the admin interface it seems that ACF gives priority to the local .json file in the theme instead of the one of the plugin.

    It’s there a way (code) that I can give the acf-json files in the plugin priority to the (same) files in the theme folder?

    Thanks for the quick reply

  • Hi @filipvanreeth

    Thanks for the post.

    It is possible to change the load point from which acf will look up the json files.

    To create a new load point (folder) for ACF to look in, please add the following code to your theme or plugin:

    <?php 
    
    add_filter('acf/settings/load_json', 'my_acf_json_load_point');
    
    function my_acf_json_load_point( $paths ) {
        
        // remove original path (optional)
        unset($paths[0]);
        
        
        // append path
        $paths[] = get_stylesheet_directory() . '/my-custom-folder';
        
        
        // return
        return $paths;
        
    }
    
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Load priority local .json files’ is closed to new replies.