30 days free. No credit card. Full access from the moment you connect your site.

Start free trial

Add Flexible Content Layout

A flexible-content field is a repeater whose rows have types. Each row is a layout with its own sub-fields, chosen from the set the field defines — which means you cannot add a row without saying which layout it is.

custom-fields/add-acf-flex-layout appends a named layout, or inserts it at a 1-based position, with its sub-field values in the same call.

At a glance

Abilitycustom-fields/add-acf-flex-layout
ToolsetAdvanced Custom Fields — toolset/acf
GroupRepeater & Flexible Content
RequiresAdvanced Custom Fields Pro, plus a flexible-content field registered on the site
Capabilitymanage_options
SafetyWrites data
RepeatableNot idempotent — each call changes the row set, so re-running is not a no-op
Ships inAcrossAI Abilities Manager 0.0.34 and later

How it works

The layout name has to be one the field actually defines. Ask custom-fields/get-acf-field for the field, or blocks/get-acf-block-fields when the flexible-content field sits behind an ACF block — both report the available layouts and the sub-fields under each.

Pointed at a plain repeater, the call is rejected with a typed error rather than guessing. Plain repeaters have no layouts; use custom-fields/add-acf-repeater-row for those.

As with repeater rows, appending is a single targeted write and inserting at a position rewrites the array to make room.

Input

NameTypeRequiredWhat it is
target_typestringNo — defaults to postWhat the value is attached to: post, user, term, comment or option. post covers pages and any custom post type.
target_idinteger | stringYes, for post, user, term and commentThe ID of the target. Optional for option, where it names a specific options page; omit it for the default options store.
selectorstringYesRepeater or flexible-content field name (e.g. cards) or field key.
layoutstringYesName of the layout to add, as the flexible-content field defines it.
valuesobjectNoSub-field name => value for the new layout.
positionintegerNo1-based position to insert at. Omit to append.
apply_wp_slashbooleanNo — defaults to trueRuns wp_slash() over your strings before writing, so literal backslashes survive. Set it false only when you have already slashed the payload yourself.

What comes back

NameTypeWhat it is
indexintegerWhere the layout landed, 1-based.
layoutstringThe layout that was added.
row_countintegerHow many rows the field holds now.
successbooleanWhether the call completed.
messagestringA one-line summary of what happened, suitable for showing a human.
error_codestringPresent only on failure — a stable machine-readable reason, such as a missing field, a wrong field type or an unmet confirmation.

Example

Ask your assistant:

Add a testimonial section to the page_sections flexible content on page 87, quoting Maya at Northwind.

It resolves to one call:

{
  "ability": "custom-fields/add-acf-flex-layout",
  "parameters": {
    "target_type": "post",
    "target_id": 87,
    "selector": "page_sections",
    "layout": "testimonial",
    "values": {
      "quote": "We shipped in a week instead of a quarter.",
      "attribution": "Maya, Northwind"
    }
  }
}

Worth knowing

  • Not idempotent. A retry adds a second layout — read the field before retrying a call whose outcome you are unsure of.
  • Sub-field names differ per layout. Two layouts can both have a title and mean different things, so read the layout’s own fields rather than assuming.
  • Requires ACF Pro. Flexible content is a Pro-only field type, so there is nothing to act on in the free edition.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading