Home Forums ACF PRO Local JSON in plugin not load


Local JSON in plugin not load

  • I’ve a problem with local json and i don’t know, it is a bug.

    I did everything that is on this page:
    But the own folder was used only for saving and not for loading.
    It works only in the master theme – not in my child-themes.

    So I put it in a plugin. Here is my code:

    But it is the same. ACF saves the JSON, but an other installation don’t read this file.

    Where is my mistake?

      // save jsonwith fields
      function bks_acf_json_save_point( $path ) {
        // update path
        $path = plugin_dir_path( __DIR__ ) . '/acf-json';
        // return
        return $path;
      // load json with fields
      function bks_acf_json_load_point( $paths ) {
        // append path
        $paths[] = plugin_dir_path( __DIR__ ) . '/acf-json';
        // return
        return $paths;
      add_filter('acf/settings/save_json', 'bks_acf_json_save_point');
      add_filter('acf/settings/load_json', 'bks_acf_json_load_point');

    I also tried the PHP variant. Everything is displayed correctly, but the repeat fields are not saved.

    • Beee

    • February 18, 2018 at 1:49 am

    You need to add the following line to the load function because only 1 path may exists per load/save.


    That being said, I think you should look into the issue why it’s not loading from the other site, because this is the default behaviour and should work, so something is blocking it.

  • Hello @beee,

    this didn’t solve the problem.

    I have removed this line, because the json from the template is also not loaded any more.

    Thanks for the try.

    • Beee

    • February 18, 2018 at 2:45 am

    Well, according to the local json info page, it needs to be unset, so that was step 1.

    What if you dump $paths in the save function ? What does it output ?

  • I do not think so. The info page says that the folder “acf-json” is one of the load points. If you look in the code of ACF, then you see that there are many folders possible. With unset I remove one of these load points. But that is not, what i want. I want many load points.

    In the plugin i want to load the fields for all my sites. In the theme i want to load the fields for a special page.

    Please have also a look at the comment over the line with unset
    // remove original path (optional)
    I don’t want to remove this path. I will use it, too.

    And how i said: It didn’t solve the problem.

    If i use var_dump in acf_json_load_point nothing would be displayed.

    • Beee

    • February 18, 2018 at 2:59 am

    You are right, I stand corrected.

    Have you tested with a higher or lower priority ?

    add_filter('acf/settings/load_json', 'bks_acf_json_load_point', 1);

    add_filter('acf/settings/load_json', 'bks_acf_json_load_point', 20);

  • Actually var_dump did a job for me within my function, and in my case revealed that plugin_dir_url( __FILE__ ) was providing a url ending with / so my constructed path of:

    plugin_dir_url( __FILE__ ) . ‘/acf-json’

    (which similar to yours above skrabbel features a / in the final part) was producing an erroneous // in the URL.

    ….frustratingly though this hasn’t resolved my issue (which has similar symptoms to the above – filtering load_json within a plugin failing to then implement the field (group) ), and the above prioritizing doesn’t either.

  • I’m having issues with the synchronization feature as well. The save point works fine. The files get stored in the right place and update each time I save a group. The sync available option, however, does not appear as predicted after I pull relevant changes from my repo onto my other machine (which, in fact, has no field groups in its DB). Neither does the option appear on the original machine after I edit the files directly. I even incremented the modified property.

    These are my save and load points:

    add_filter('acf/settings/save_json', 'p2c_acf_json_save_point');
    function p2c_acf_json_save_point( $path ) {
        $path = plugin_dir_path(__FILE__) . 'fields/acf-json';
        return $path;
    add_filter('acf/settings/load_json', 'p2c_acf_json_load_point');
    function p2c_acf_json_load_point( $paths ) {
        $paths[] = plugin_dir_path(__FILE__) . 'fields/acf-json';
        return $paths;

    Permissions on the directory are writeable. I use username:www-data as owner:group in my local environment with 775 permissions.

    I also tried adjusting the priority of the filters to no effect. plugin_dir_path() already provides the trailing slash and I verified that the correct directory is pushed to $paths (and the default removed).

    Any ideas?

    • nevma

    • September 15, 2019 at 11:33 pm

    We are having similar issues, but from within a theme. It is like the filter acf/settings/load_json never fires from within functions.php. Even if we put a PHP exit call in the function nothing happens.

  • If your filter is not running then the likely causes are:

    1) Your add_filter('acf/settings/load_json' ..... line of code is never running

    2) Your add_filter('acf/settings/load_json', ..... line of code is run after the hook has fired.

    So the question is “When” is the filter being added?

    • nevma

    • September 16, 2019 at 12:55 am

    I just found the solution to the problem. My hooks were registered in the functions.php but I did it after having called get_field() a little bit earlier. Calling get_field() initialises ACF and thus the hooks were useless afterwards.

    Seems so simple now, but was quite hard to grasp…

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.