Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Advanced Custom Fields is used on the IBE site in for a manybunch of reasons:

  • Custom Post Types: It is used to add custom meta fields to custom post types.

    • The ACF data can be found in the /public/assets/acf folder of the custom post type plugin. In that folder, there is a PHP file that loads the fields and a JSON export that is needed when updating the fields.

  • Gutenberg Blocks: Some of the custom Gutenberg blocks on the site use the ACF blocks functionality.

    • IBE Flow Block

    • Impact Block

  • Theme: The PHP and JSON files for these fields can be found in understap/inc/acf. They are used for a few things:

    • Theme options including the alert bar settings.

    • Custom widgets used for the sidebars on custom post types.

...

Out of the box, ACF is built to store the field groups in the database. Obviously, that poses some challenges when you are developing a site with multiple environments. There are a couple options for solving this problem, the one that works best for multisite is registering the fields in PHP. (The other option is local json, but that would require touching evenry every site when you make an update.)

What I have been doing is building the field groups in the dasboard dashboard (Custom Fields in the left side menu) and then exporting them to PHP and JSON. The PHP is put into a file which is loaded with the plugin/theme. I then delete the field group from the database.

Saving the JSON makes it possible to re-import the field group into the database to edit in the future. It is also possible to edit the PHP directly, but then your JSON is out of sync, so I don’t recommend that. If you have a very small change, you could possibly manually edit both the JSON and the PHP file.

...