Support

Account

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.