Skip to content

Advanced Custom Fields

Alex Prokopenko edited this page Sep 11, 2018 · 1 revision
- Article is under construction

It's hard to imaging a theme without some extra configurations and custom fields. The most popular plugin for this is an Advanced Custom Fields.

It's really great, however keeping fields configuration inside a database has few disadvantages:

  • You need to export/import settings between development and production servers.
  • You need to have different DB instances if you work on very different fields configurations (for example, you are working on big site update, but still need to do a hotfixes for current version).
  • You can't track field configuration changes (who and when updated something).
  • You can't revert configuration quickly if you don't have an old exported config.

We believe that fields configuration have to be stored under VCS, this makes all processes easier and resolve all issues mentioned above. We found a good package which can help you with defining fields inside the code: https://github.com/StoutLogic/acf-builder/wiki

Also our framework has several classes to make it even more simplier to define your fields: Framework ACF Support.

We recommend to store your fields in such structure:

/app/
    /Fields/
        /Modules/
            Fields_Foo      # generic fields definitions, which can be used in other classes
            Fields_Bar
            ...
            Module_Foooo    # Modules fields definitions
            Module_Baaar
        
        Page_Fields         # Fields grouped by content structure (content type, user, tax, option page)
        User_Fields
        ...
        Theme_Fields