Home Forums General Issues Registering Fields Upon Theme Installation


Registering Fields Upon Theme Installation

  • Hello,

    I’ve run into an issue with ACF (which is amazing by the way) and I feel like I m,ight be missing something in what I’m attempting to do.

    Back story time…

    I’m developing a custom WordPress theme and I’m trying to include ACF pro in with the theme’s files. So far all the documentation I’ve found has been extremely helpful in helping me do this, and the theme is moving along swimmingly.

    However, I’ve been trying to find a way to auto register certain flexible content fields and option fields upon theme installation.

    I’ve tried using the local JSON to no effect. When I export my fields, then create the acf-json folder within the theme and then sync, I get a “no title” field with nothing in it.

    I’ve tried adding the “acf/include_fields/add_theme_field_groups” snippet to the functions.php file and that does not create any of the desired fields in the backend.

    I’m probably missing something with one of these processes, which is why I’m here, desperate for a little help.

  • 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(
        // field group 1 settings
        // 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.

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

The topic ‘Registering Fields Upon Theme Installation’ is closed to new replies.