Support

Account

Home Forums General Issues How to auto sync json acf groups in multisite network? Reply To: How to auto sync json acf groups in multisite network?

  • Rather than build code in the child theme that adds a load point I have this code in the parent theme to reduce code in the child theme.

    In the funcitons.php file of the parent theme I have

    
    add_filter('acf/settings/load_json', 'parent_theme_acf_json_load_point);
    function parent_theme_acf_json_load_point($paths) {
      if (!is_child_theme()) {
        return $paths;
      }
      array_unshift($paths, get_template_directory().'/acf-json');
      return $paths;
    } 
    

    The reason I use array_unshift() is to ensure that the parent json files will be first and override the child theme because I do not allow changes to these field groups in the child theme. If more fields are needed for a specific child theme then these field must be created by adding additional field groups to the child theme.

    This could be done in the child theme, but like I said, it’s added code in every child theme. To me this is like the way most people build themes where when using a child theme the developer must do extra work to enqueue the parent theme’s stylesheet when they can simply check in the parent theme to see if a child theme is being used and automatically add both the parent theme’s stylesheet and the child theme’s stylesheet in the correct order with the correct dependencies to begin with. Little QOL improvements to keep me sane and reduce my workload.