Support

Account

Home Forums General Issues Parent & Child Theme JSON Sync

Solved

Parent & Child Theme JSON Sync

  • Hey guys,

    I’m trying to build a multisite platform with one main Parent theme and several Child theme options. I’m using a ton of ACF throughout to make both the parent theme and then the specific customizations in the child theme.

    I would love to be able to do the JSON sync in both the parent theme and the child theme. That way I can sync everything across the whole network, including the child theme specific field groups. But from what I’m reading, doesn’t seem like that is doable?

    I understand that exporting it to PHP for the child themes is probably the best option, but I wouldn’t be able to edit it as easily in the future.

    Just wanted to see what the options are!

    Thanks so much

  • I would set second load point for field groups for the 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;
    }
    

    Then I would work on changes to fields in the parent them only on a site that uses the parent theme. I would not Sync, or allow these field groups to be changed in the child theme.

    If I want to have additional fields groups in child themes I would only add fields to a site using that theme. Since each child theme would also have an acf-json folder, these files could be synced to any other site using that theme.

  • Interesting! So it can work, that’s awesome.

    Just to make sure then, right now I have one site that’s using the child theme and I’ve been building all of the custom fields on that one. So what I would do is start a new site with parent theme activated, import the parent theme fields there, sync it with JSON, then delete the parent theme fields on the child theme site so that they only show up from the JSON?

    As always, thanks so much John!

  • Looks like it might have worked! Can’t delete them, just sync them, I think. The one thing that might be tough is not having automatic syncing though. As we develop new features with the sites, we’ll just have to release them manually in each one? Might be helpful to have more of an eye on it, but do you know if there are any plans for automatic syncing at some point?

  • So you’ve been working in the child theme. I would try exporting the fields and importing them into the site using that parent theme. Then deleting the field groups from the child theme. If the parent theme has an acf-json folder then the filter I posted should load them into the child theme.

  • Yep, seems to be working great right now! And even is automatically syncing, not sure how that’s happening.

    So I used the code you provided in both the parent and child themes and then I’ve been making tweaks to the parent theme fields in the site with the parent theme, and then the child theme fields in one that has the child theme installed. Not exactly sure how it all works, but seems to be!

    Thanks John!

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

You must be logged in to reply to this topic.