bricks_create_acf_field_group

Phase 2AdvancedComplexity: 8/10
Create an ACF field group with fields and location rules

Overview

Creates an ACF (Advanced Custom Fields) field group with fields and location rules. Supports 20+ field types including text, image, repeater, relationship, taxonomy, and more.

Location rules control where the field group appears in the WordPress admin (e.g., on specific post types, page templates, or user roles). The tool generates a PHP file in the child theme for persistence across deployments.

This is the primary tool for defining custom data structures that power dynamic content in Bricks templates via {acf_field_name} dynamic data tags.

Key Features

20+ Field Types
Supports text, textarea, number, email, url, password, wysiwyg, image, file, gallery, select, checkbox, radio, true_false, link, date_picker, color_picker, repeater, group, relationship, taxonomy, and user field types.
Nested Sub-Fields
Repeater and group field types support sub_fields for creating complex nested data structures like feature lists, team member details, or pricing tiers.
Location Rules
Flexible location rules based on post_type, page_template, user_role, or taxonomy. Rules use AND logic within a group and support == and != operators.
Persistent PHP Generation
Generates a PHP registration file in the child theme, ensuring the field group persists across deployments and is version-controllable.

When to Use

You need custom fields on posts, pages, or custom post types
You are building a dynamic Bricks template that needs structured content (hero settings, team details, pricing data)
You want repeater fields for flexible content like feature lists or FAQ items
You need relationship fields to connect posts across post types
You are setting up a custom post type and need its data schema
Prerequisites
ACF Pro plugin must be installed and activated
A child theme must be active (use bricks_ensure_child_theme first)
The target post type should exist if using location rules based on post_type

When NOT to Use

You prefer Meta Box over ACF — use bricks_create_mb_field_group instead
The field group already exists and you want to update it — manage through ACF admin
You only need to set field values — use bricks_set_acf_values

Parameters

4 Total Parameters3 Required1 Optional

Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
titlestringREQUIRED
Field group title displayed in the ACF admin (e.g., "Hero Settings", "Team Member Details").

Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
fieldsarray of objectsREQUIRED
Array of field definitions. Each field has: name (string, lowercase with underscores), type (enum of 20+ types), label (string), required (boolean, optional), default_value (optional), instructions (string, optional), choices (key-value object for select/checkbox/radio), min/max (numbers), return_format (string), sub_fields (array for repeater/group), post_type (array for relationship), taxonomy_type (string for taxonomy).

Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
location_rulesarray of objectsREQUIRED
Location rules controlling where the field group appears. Each rule has: param (e.g., "post_type", "page_template"), operator ("==" or "!="), value (e.g., "page", "post").

Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
positionstring (enum)optional
Position of the field group on the edit screen. One of: normal, side, acf_after_title.
Default: normal

Code Examples


Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12

Create a Hero Settings field group

Creates fields for hero title, background image, and CTA button text on pages.

JSON
bricks_create_acf_field_group({
  title: "Hero Settings",
  fields: [
    { name: "hero_title", type: "text", label: "Hero Title", required: true },
    { name: "hero_background", type: "image", label: "Background Image", return_format: "array" },
    { name: "hero_cta_text", type: "text", label: "CTA Button Text", default_value: "Get Started" },
    { name: "hero_cta_link", type: "url", label: "CTA Link" }
  ],
  location_rules: [
    { param: "post_type", operator: "==", value: "page" }
  ],
  position: "acf_after_title"
})

Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12

Create a repeater field group for features

Creates a repeater field with sub-fields for icon, title, and description on a custom post type.

JSON
bricks_create_acf_field_group({
  title: "Service Features",
  fields: [
    {
      name: "features",
      type: "repeater",
      label: "Features",
      sub_fields: [
        { name: "icon", type: "text", label: "Icon Class" },
        { name: "title", type: "text", label: "Feature Title" },
        { name: "description", type: "textarea", label: "Description" }
      ]
    }
  ],
  location_rules: [
    { param: "post_type", operator: "==", value: "service" }
  ]
})

Common Mistakes


Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
The MCP TypeScript tool accepts location_rules as a flat array of rule objects and transforms it internally to ACF's nested format [[{param, operator, value}]]. If the PHP endpoint does not receive the location key, it falls back to post_type == "post". Verify the generated PHP file has correct location rules.

Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
The tool generates a PHP file in the child theme directory. If no child theme is active, the file cannot be created. Run bricks_ensure_child_theme before creating ACF field groups.

Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Field names must be lowercase with underscores only (e.g., "hero_title" not "Hero Title" or "heroTitle"). Invalid names will cause ACF to fail silently when saving or retrieving values.

Tips & Warnings

Tips & Warnings

Tip: After creating a field group, use bricks_create_post to populate content in the custom post type, including ACF field values via the meta parameter.

Tip: For repeater fields used with Bricks query loops, set the return_format of sub-fields appropriately. Image sub-fields should use « array » or « url » format for compatibility with Bricks dynamic data tags.

Warning: Known parameter mismatch: the TypeScript tool sends location_rules but the PHP endpoint expects location. The tool handles this transformation internally, but if you see fields appearing on the wrong post types, check the generated PHP file in {child-theme}/bricks-mcp/.

Warning: ACF Pro is required. The free version of ACF does not support repeater, group, or gallery field types.

Return Values

FieldTypeDescription
field_group_idstringThe generated ACF field group key/ID.
fieldsarrayThe registered field definitions with their generated keys.
file_pathstringPath to the generated PHP file in the child theme.

Related Tools

Technical Details

Tool ID
bricks_create_acf_field_group
API Endpoint
/acf/field-groups
HTTP Method
POST
Namespace
acf
Source File
acf/field-groups.ts
Version
1.0
Min Bricks Version
1.9
Requires Plugin
ACF Pro
Requires Auth
Yes

Changelog

v1.0
Initial release with support for 20+ ACF field types, nested sub-fields, location rules, and child theme PHP generation.
20250101