Home › Forums › General Issues › Registering Fields Upon Theme Installation › Reply To: Registering Fields Upon Theme Installation
The best way to do this is to create a folder named
acf-json in your theme folder. Then save all of the field groups. This will automatically save each field group in the theme and when this theme is installed these field groups will automatically be used in the theme.
The format of the field groups when exporting from ACF is different than the format of the field groups in the acf-json folder and what is expected there. In the json folder each file contains an array representing each field group, a representation would be something like
$group = array( // field group settings )
When exporting what you get is a multidimensional array containing 1 or more field groups that could be represented by something like
$groups = array( array( // field group 1 settings ), array( // field group 2 settings ), )
The only downside to using the acf-json folder is that the field groups cannot be modified after theme install, however, I would think that would be the goal for a theme that someone else would install.
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.