Insert ACF Block

ACF block values do not live in post meta. They are serialised into the block’s own comment delimiter inside the post content, which is why custom-fields/update-acf-field cannot touch them — and why writing them by hand means editing block markup.

blocks/insert-acf-block puts a block instance into a post with its field values in the data payload, serialised the way the editor expects.

At a glance

Abilityblocks/insert-acf-block
ToolsetAdvanced Custom Fields — toolset/acf
GroupACF Blocks
RequiresAdvanced Custom Fields Pro
Capabilitymanage_options
SafetyWrites data
RepeatableNot idempotent — each call inserts another instance
Ships inAcrossAI Abilities Manager 0.0.34 and later

How it works

Give it a post ID, the block name and a data object keyed by field name. Omit index and the block is appended; pass one and it lands at that 0-based position among the post’s top-level blocks.

Note the indexing difference: block positions are 0-based here, while repeater and flexible-content rows are 1-based. That split is ACF’s own, and this suite follows each API rather than papering over it.

Call blocks/get-acf-block-fields first. A key that matches no field is written into the payload and then ignored by the block — a silent no-op rather than an error.

Input

NameTypeRequiredWhat it is
post_idintegerYesThe post to insert the block into.
namestringYesBlock name, with or without the acf/ prefix.
dataobjectNoField name => value for the block, matching blocks/get-acf-block-fields.
indexintegerNo0-based position among the post’s top-level blocks. 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
post_idintegerThe post that was written.
namestringThe block that was inserted.
indexintegerWhere it landed, 0-based.
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 block to post 412, quoting Maya at Northwind, just after the intro paragraph.

It resolves to one call:

{
  "ability": "blocks/insert-acf-block",
  "parameters": {
    "post_id": 412,
    "name": "testimonial",
    "data": {
      "quote": "We shipped in a week instead of a quarter.",
      "attribution": "Maya, Northwind"
    },
    "index": 1
  }
}

Worth knowing

  • Not idempotent — each call inserts another instance.
  • Page builders are the exception to all of this. If a post is built with Elementor or similar, its layout is not in the post content, and inserting a block there changes nothing a visitor sees.
  • To change a block already in a post, use blocks/update-acf-block-data rather than inserting a second one.
  • Requires ACF Pro.

Related abilities


Get the plugins:
AcrossAI Abilities Manager · AcrossAI MCP Manager

Browse the rest: Every ability, by category


Keep reading