Support

Account

Home Forums General Issues Json on child theme Reply To: Json on child theme

  • I’ve found a way to do it using the code here: https://gist.github.com/joelstransky/053d18846d3e42631aec773e4346e2ca

    1. In child theme Load ACF field groups from parent:

    // Load ACF Fields from Parent Theme
    add_filter('acf/settings/load_json', 'parent_theme_field_groups');
    function parent_theme_field_groups($paths) {
      $path = get_template_directory().'/acf-json';
      $paths[] = $path;
      return $paths;
    }

    2. In parent theme get child theme ACF JSON variants to overwrite parent theme:

    add_filter('acf/settings/save_json', function() {
      return get_stylesheet_directory() . '/acf-json';
    });
    
    add_filter('acf/settings/load_json', function($paths) {
      // $paths will already include the result of get_stylesheet_directory ie. parent theme's acf-json
      if(is_child_theme()) {
        $paths[] = get_template_directory() . '/acf-json';
      }
      return $paths;
    });

    3. Create /acf-json/ folder in child theme. Copy required ACF field group files from parent to child (only ones that will need customising). Sync these files in your child theme ACF Field Groups list.