Home › Forums › Gutenberg › Local JSON in ACF Blocks › Reply To: Local JSON in ACF Blocks
You cannot use exported JSON files for this. To add local JSON to a plugin.
1) add the acf-json folder to your theme
2) create field groups
3) download the json files for you field groups from your theme folder
4) upload the json files to the acf-json folder in your plugin
5) Add the path to your plugin json files with acf/settings/load_json
Note, you cannot use acf/settings/save_json the way you are using it. This will cause all field groups on the site to be saved in your plugin folder. In order to do this you must check the field group field group to make sure that it is one of the field groups used by your plugin before adding the save location hook. This can be done using the acf/update_field_group filter to check the field group and if it is one of yours then add the acf/settings/save_json filter.
If you do not want the field groups to by sync-able then you add then you can set them as private, that is discussed here https://www.advancedcustomfields.com/resources/synchronized-json/. This must be done manually because when saving a field group in the admin, if you are using acf/settings/save_json hook then the private setting will be removed when the groups is saved in the admin. It is possible to use the acf/prepare_field_group_for_export hook to create a filter that can set the private value of the field group dynamically based on something else. I have done this in the past by defining a custom constant on my dev sites so that I can check this and set the private value based on this constant being defined.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re hard at work on ACF 6.1, and Beta 1 is now available 🚀— Advanced Custom Fields (@wp_acf) March 16, 2023
This release includes custom post type and taxonomy registration, an improved experience when selecting field types, PHP 8.1 and 8.2 compatibility, and more!
Let’s take a look 🧵https://t.co/Y0WcAT11l4
© 2023 Advanced Custom Fields.