Snapshot revisions before a bulk edit

MaintenanceAdvanced~30 minUpdated

Before you start

A connected site with content reads on and the post write abilities enabled for the write pass. The agent needs edit access to the posts. WordPress revisions on, and the manage-options capability to read the activity log.

A find-and-replace across a batch of posts is the kind of change that is quick to run and slow to unpick if it catches something it should not. The confidence to run it at all comes from two things: knowing you can put any single post back exactly, and being able to prove afterward precisely what was touched.

This recipe builds both in before it changes anything. It records a per-post rollback point, makes the change in batches you approve, and then reads the plugin’s own audit log so you can see every write it made.

The prompt
I need to change [our old company name] to [the new one] across [the posts in
the "News" category], and I want a clean rollback plan before we touch a thing.
Go read-first. Pull the posts in [News] that mention [the old name] and show me
the list. For each one, list its revisions and record the current latest
revision ID, that is our rollback point per post. If a post has no revisions at
all, paste its full current body, as raw block markup, into your reply as its rollback copy. Then show me a
before-and-after for a small sample of the exact replacement so I can see it is
a clean swap and not catching words it should not.
I approve before any write. After I say go, make the change in small batches,
one post at a time within each batch, and show me each batch before it saves.
The replacement only works on plain visible text, so list any post where the old
name sits inside a tag or attribute such as an href or src as skipped. Every edit saves a fresh
revision on its own, so combined with the IDs you recorded, each post has an
exact point to return to.
When the run is done, read the activity log newest first, 200 rows a page,
until created_at (UTC) is older than when we started, and show me every write
it recorded for this job: the ability, the post, the acting user, and the time.
The read has no date filter, so stop paging at the start of the run. If any
post looks wrong, I will hand its recorded revision ID to the
restore-a-revision recipe and roll just that one back.

Why this is safe to run

The whole setup is reads. Finding the posts, listing each one’s revisions, and previewing the replacement on a sample all write nothing, so you approve the exact change and you hold a recorded rollback point for every post before a single edit runs.

The change itself goes out in small batches you see first, and it only edits post bodies, never status. It also only changes plain visible text and refuses a match inside a tag or attribute such as an href or src, so those posts come back as skipped. WordPress saves a revision after each save, so a post that has been saved before has both its recorded starting point and a clean history, and one with no revisions has the body copy the agent pasted into the chat, and rolling one back is a handoff to the restore-a-revision recipe, whose restore is itself reversible. The Changes tab in wp-admin lists each replace-in-post edit as well, and Revert puts a post back if it hasn’t been edited since, which is a second route besides the recorded revision ID. When the run is done, the activity log gives you the receipt: every write, the post it hit, who the agent acted as, and when. The write abilities stay off until you enable them, every call is checked against the capability of the user you bound the agent to, and reading the log needs the manage-options capability.

For a receipt you can keep, open the Activity Log tab afterward, set the From date to today, filter by the tool you used, and Export CSV. The tab shows the connection, the source IP and the duration of each call, which the agent’s read does not return.

Already connected? You do not have to paste this. Ask your agent for the “snapshot revisions before a bulk edit” recipe, or just describe the sweeping change you are nervous about, and it runs the same read-first, fully logged flow on your own site.

How it works

  1. Pull the posts in the set you name that match the change and list them.
  2. List each post's revisions and record the current latest revision ID as its rollback point, and for any post with no revisions, paste its current body into the chat instead.
  3. Show a before-and-after for a small sample of the exact replacement, and wait for approval.
  4. Apply the change in small batches, one post at a time within a batch, pausing to show each batch, and report any post where the text sits inside a tag or attribute such as an href or src as skipped.
  5. Read the activity log back to the start of the run and report every write for the job: the ability, the post, the acting user, and the time.

Questions

How is the rollback point captured?
WordPress saves a revision after each save, so a post that has been saved before has a latest revision holding its current text. Before the run, the recipe records that revision ID as the exact point to return to. A post with no revisions has none, so the agent pastes its body into the chat instead.
How do I actually roll a post back?
Hand the recorded revision ID to the restore-a-revision recipe. A restore returns the whole post to that revision, so its title and excerpt go back too, not only the body. The restore takes no snapshot of its own, so check that the live version is already the newest revision first.