Undo a change
wp_undoReverses one earlier WordPress change with its undo token, restoring posts, statuses, settings, builder pages, or themes; dry_run previews restores and blocks without changing data.
Instructions
Reverse one earlier change using its undo token (from the "undo" field of the original result, or from wp_undo_list): the fields of a post changed with wp_update_post, the statuses wp_bulk_update_status set, the site settings changed with wp_update_site_settings, the page-builder pages wp_update_builder_element and wp_search_replace changed, or the theme wp_activate_theme switched from (also through wp_install_theme_zip with activate). dry_run=true shows exactly what would be restored and what refused, without changing anything; wp_undo_discard drops a point without restoring it. Undoing needs the same permission as the original action, and each item is re-checked against the CURRENT state, so a post this account may no longer edit is reported as blocked rather than restored. An undo of a page-builder change (wp_update_builder_element, wp_search_replace) puts every stored copy of the page back byte for byte and refuses a page that someone has changed since — restoring would throw that newer work away — unless force=true. A fully successful undo consumes the token. A partial one consumes it too and returns rest_token, a new undo point with only what did not come back, so a later call retries just that; where nothing came back, the token is kept. A theme is switched back the way wp_activate_theme switches, with the same test requests: probe lists their result, and where the site does worse with the previous theme, the theme active before the undo is put back in the same call, the item is listed under failed with the reason, and the token is kept. Afterwards the page caches of the supported caching plugins are asked to purge the restored posts, and after an undo of site settings or of a theme every page of this site; page_cache_purged lists them, page_cache_skipped names a cache left out on a multisite network and why.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Page-builder undo points only: true restores a page even where it was changed after the change being undone, which throws that later change away. Default false: such a page is reported as blocked (changed_since). | |
| token | Yes | The undo token, e.g. undo_1a2b..., from the undo field of the original result or from wp_undo_list. | |
| dry_run | No | true returns what the undo would restore and changes nothing. Default false. |