Replace a leftover block with a core block, page by page

ContentAdvanced~15 min

Before you start

Plugin version 1.10.0 or newer. The block reads and Replace block are off until you switch them on; Replace block is a write, so enable it only for the write pass. The agent needs edit access to each page. Pages owned by Elementor, Divi, Beaver Builder or Avada are refused. Turn on WordPress revisions first. Run find pages with blocks your site no longer has first, for the list of pages and paths.

Say twelve pages still hold an old plugin’s call-to-action block, and each needs the same fix: a core group with a heading, a line of text and a button. By hand that is twelve trips through the editor. A full-page rewrite would mean trusting the agent with every other block on those pages.

Start from the list made by find pages with blocks your site no longer has. Replace block changes one block per call, and the agent stops for your yes on each page and checks the block name before it writes.

The prompt
Replace the leftover [old-plugin/cta] blocks with a core block. Here is
the list of pages and paths from the find-pages run: [paste the table].
1. The replacement is a core/group holding a core/heading, a
core/paragraph and a core/buttons block with one core/button. Check
that each of these block types is registered and read the attributes
they accept, so the markup is valid.
2. For each page, in order:
- read the page as raw block markup and confirm the block at that path
is [old-plugin/cta]
- write the new block, reusing that block's own heading and button text
and link
- show me the old markup and the new markup side by side, and wait
3. When I say go for a page, replace only that block, passing the path and
the expected block name so the call refuses if the page has changed.
Tell me about any content warnings the tool returns.
4. Read the page again and confirm the new block is at that path.
Keep a copy of every old block in your reply. At the end, list pages
replaced, refused (with the reason) and skipped.

Why this is safe to run

The reads come first, and every write is one Replace block call you approved for that page. Pass the expected block name, and a page that changed since the list was made is refused rather than overwritten. The old markup stays in the chat. If a page’s existing markup cannot be saved back cleanly, the call refuses too, and that page is one to fix in the editor.

Replace block is off until you switch it on, it is checked against the edit access of the connected user, and each call lands in the Activity Log. With revisions on, every page keeps its earlier version in its history.

Already connected? Ask your agent to replace the leftover blocks it found, one page at a time, and approve each swap as it comes.

How it works

  1. Take the list of leftover blocks by page and path.
  2. Agree on one core replacement and check each block type it uses.
  3. For each page, show the old block and the exact new markup side by side.
  4. Replace only that block after your yes, passing the path and expected block name.
  5. Read the page back and report replaced, refused and skipped.

Questions

Will the rest of the page change?
Replace block swaps one block and leaves the other blocks' parsed attributes and HTML as they were. WordPress may still sanitize the whole page on save for users who cannot post unfiltered HTML, which is normal WordPress behaviour.
How does a nested leftover get replaced?
By its path: its position among the top-level blocks, then inside each parent. [3, 1] is the second block inside the fourth top-level block. The find step records that path, and the agent passes it with the block name it expects there.
Can I undo a swap?
With WordPress revisions on, each saved change creates a revision, and you can restore the earlier version from the page's history.