ACF Chef#

ACF Chef is a fluent builder for declaring Advanced Custom Fields field groups in PHP. It builds on vinkla/extended-acf and uses its field classes and native field APIs.

ACF accepts nested arrays. extended-acf provides an object API for those arrays. ACF Chef adds a declaration tree to that API. You declare fields with short method names, nest containers with closures, and reuse shared definitions in any container. You can edit the field tree until it is compiled.

use AcfChef\Chef;

add_action('acf/init', function () {
    Chef::group('hero', function ($group) {
        $group
            ->text('title')
            ->image('background')
            ->location('post_type', 'page');
    })->register();
});

What ACF Chef adds#

  • Field methods that need only a name and derive the label from it.
  • Closures for nesting groups, repeaters, flexible content and layouts.
  • Reusable recipes and edits that identify fields by path before compilation.
  • Readable field keys based on paths by default.
  • Conditional references resolved against the complete field tree.
  • Custom field types, macros and configuration shorthands for your project, registered without forking the package.
  • Data migrations for saved values that would otherwise lose their connection to fields when you restructure a field group.

ACF Chef compiles the finished tree into the array ACF expects. During compilation, it creates extended-acf field objects, applies native configuration that was deferred, resolves references between fields and generates the final keys.

Start here#

Read Why ACF Chef to compare it with raw ACF arrays and plain extended-acf.

Follow Getting started to install the package and display a field group.

Read How it works to understand how the API describes and compiles field groups.

Read Data migrations when you need to change a field group that already has saved data.