Undo a bad edit by restoring a revision

ContentBeginner~5 minUpdated

Before you start

A connected site with content reads on and the restore-revision write ability enabled. The agent needs edit access to the post. WordPress revisions must be on for that post, which they are by default. A restore puts back the whole revision, so the title and excerpt return to that version too, not only the body. Pages owned by a page builder are refused, except, since 1.12.0, Avada and WPBakery pages while that builder is active. List changes and Undo change are optional and off until you enable them; they see only this connection's own edits from the last 24 hours.

Everyone has that moment: an edit went sideways, a paragraph got mangled, a good version of a page is now buried under a worse one. WordPress has kept every revision the whole time, but scrolling the revision comparison screen and being sure which one to restore is the fiddly part.

This makes the undo a short conversation. The agent lists the history, shows you the version you are about to bring back with a diff against what is live, and restores it only once you confirm.

The prompt
Something got mangled in my [pricing] page in an edit earlier and I want to put it
back to the version from before.
If this connection made the bad edit in the last 24 hours, check list-changes
for the page first. If undo-change can revert it, use that instead of a
revision.
Otherwise, read only to start. List the revisions on [the pricing page] with their dates and
who saved them, and help me spot the last good one. Show me that revision's content
and a diff against what is live now so I am sure it is the right point.
Once I confirm which revision, check that what is live now is already the
newest revision: read the newest one with a diff against the live page. The
restore takes no snapshot of its own, so if they differ, paste the live title,
excerpt and body into your reply first so I have a copy. Tell me too whether
the title and excerpt differ in the revision I picked, since the restore brings
those back. Then restore the page to it.

Why this is safe to run

Listing the revisions and reading one are reads, so you review the exact content you are about to bring back, and its diff against the live page, before anything is restored. There is no guessing from a date alone. If the bad edit came from an agent using one of the 25 covered tools, the Changes tab in wp-admin is the quicker way back, and revisions are the route for edits it doesn’t cover.

The restore takes no snapshot of its own. The live version survives only if it is already the post’s newest revision, which is normal while revisions are on, so the agent checks that first and copies the live text into the chat when it is not. The restore is refused outright when revisions are off for the post, since the current state could not be kept. Nothing in the revision history is deleted. The restore and undo abilities stay off until you enable them, each call is checked against the capability of the user you bound the agent to, and it lands in the Activity Log with the post it changed.

For an Avada or WPBakery page, roll back an Avada or WPBakery page edit covers the extra checks those restores run, and how to use the restore_revision_id their edits return.

Already connected? You do not have to paste this. Ask your agent for the “undo a bad edit by restoring a revision” recipe, or just tell it which page went wrong, and it runs the same read-first flow on your own site.

How it works

  1. List the revisions on the post with their dates and who saved them.
  2. Help you spot the last good version.
  3. Show that revision's content and a diff against what is live now.
  4. Wait for you to confirm the revision.
  5. Check that the live version is already the newest revision, or paste it into the chat, then restore. The restore takes no snapshot of its own.

Questions

Is restoring risky if I pick the wrong revision?
It can be. The restore takes no snapshot of its own. The live version survives only if it is already the post's newest revision, which is normal while revisions are on. So the agent checks that first, and when it is not, copies the live text into the chat before it restores.
Does this delete the newer revisions?
No. Restoring rolls the live content back to an older revision and leaves the history intact. WordPress normally saves the restored version as a new revision too, so nothing in the history is lost. What the restore does not keep is the version that was live before it, unless that was already the newest revision.