13
Total Abilities
7
Read
5
Write
1
Delete
Overview
The Blocks module provides surgical access to individual Gutenberg blocks within a post’s content. Instead of reading, modifying, and rewriting the entire post_content, you can parse the block tree, locate specific blocks by type or attribute, update their properties, insert new blocks at specific positions, or remove blocks — all without touching the surrounding content.
This module works alongside the Content module. Content gives you post-level CRUD; Blocks gives you block-level precision within a post.
Ability Reference
| Ability | Type | Description |
|---|---|---|
blocks/parse | R | Parse a post’s content into a block array. Returns block name, attributes, innerHTML, and innerBlocks. |
blocks/find-in-post | R | Find blocks in a post by block name, className, or attribute value. Returns matching blocks with their paths. |
blocks/find-nested | R | Search for blocks within nested innerBlocks structures. Deep recursive search. |
blocks/get-at-path | R | Get a specific block by its path in the block tree (e.g., [2, 0, 1]). |
blocks/get-type | R | Get the registered block type definition — attributes schema, supports, category. |
blocks/list-types | R | List all registered block types on the site. |
blocks/serialize | R | Convert a block array back into HTML block markup ready for content/update. |
blocks/insert | W | Insert a new block at a specific position in a post’s block tree. |
blocks/update-attributes | W | Update attributes on a block found by path. Merges with existing attributes. |
blocks/update-at-path | W | Replace an entire block at a specific path in the tree. |
blocks/replace | W | Replace a block matching search criteria with new block markup. |
blocks/append-inner | W | Append a block as a child of an existing block’s innerBlocks. |
blocks/remove | D | Remove a block at a specific path from a post’s block tree. |
Common Workflows
Find and update a specific block
1. blocks/find-in-post → search by blockName or className
2. blocks/get-at-path → verify the block at the found path
3. blocks/update-attributes → merge new attributes
⚠️ Do NOT use on text-containing blocks — destroys innerHTML
Add a section to an existing page
1. content/append → append block markup (no read needed)
OR
1. blocks/parse → get current block tree
2. blocks/insert → insert at specific position
Note: content/append is simpler when adding to the end
Known Gotchas
blocks/update-attributes destroys innerHTML. When used on text-containing blocks (paragraphs, headings, lists), the innerHTML is lost. The block saves with correct attributes but empty text. Use only on wrapper Groups or structural blocks with no text content. Recovery: revisions/restore.
blocks/insert loses innerBlocks on nested structures. When inserting a block that contains innerBlocks, the inner structure may not be preserved by serialize_block(). Prefer content/append with pre-serialized block markup for complex nested content.
Path indexing is zero-based. Block paths like [2, 0, 1] mean: third top-level block → first innerBlock → second innerBlock. Off-by-one errors are common. Always verify with blocks/get-at-path before modifying.
Related Modules
Content Module
17 abilities — post-level CRUD
Revisions Module
5 abilities — recovery from block damage