WordPress revisions: find, restore, limit and delete

WordPress saves earlier versions of your posts and pages as revisions. This guide is for anyone who edits a WordPress site and wants to look at an old version, undo a change, or keep the revision list from growing without limit.

Where to find revisions

Open the post or page in the editor. Open the Settings sidebar with the gear icon, select the Post or Page tab, and click the number next to Revisions.

In WordPress 7.0 and later, this opens a new revisions screen. In WordPress 6.9 and earlier it opens the classic revisions screen.

Revisions are stored for each saved draft and each update of a published post. Autosaves are a special kind of revision: WordPress keeps at most one per user and post and overwrites it with each new autosave. The revisions list marks them with an Autosave label.

Compare two versions

On the new revisions screen, pick a version from the list in the Revision panel or drag the slider at the top. Colored markers next to the scrollbar show where blocks changed: solid green for added blocks, red diagonal stripes for removed blocks, yellow diagonal stripes for modified blocks. Click a marker to jump to that spot. The Show changes icon next to the slider switches the highlights on and off.

To compare any two versions, use the classic revisions screen. In WordPress 7.0, open it with Open classic revisions screen in the sidebar. Turn on Compare any two revisions. The slider then has two handles, one for the version you compare from and one for the version you compare to. The classic screen shows both versions side by side as HTML, with added and removed lines highlighted.

Restore a revision and what it undoes

Find the version with the slider and click Restore.

A restore puts the old version in place of the current one. Everything saved after that version is gone from the page: a corrected phone number, a new paragraph, a fixed typo. Another person’s later edits go with them. Compare the revision with the current version first, and write down any later changes you want to keep.

If only one passage was wrong, do not restore. Copy that passage from the old version into the current page instead. After a restore, open the public page in a private browser window and check it.

Revisions not showing

Work through these causes in order.

  1. The sidebar panel is hidden. In the block editor, open the three-dot menu in the top toolbar, choose Preferences, and check Document settings. Panels you switch off there disappear from the Settings sidebar.
  2. WP_POST_REVISIONS is set to false or 0 in wp-config.php. WordPress then stores no revisions, apart from the one autosave per post.
  3. The post type does not support revisions. For such a post type, WordPress sets the number of revisions to keep to 0, whatever WP_POST_REVISIONS says. Developers enable it with the revisions feature on the post type.
  4. A plugin overrides the limit. The wp_revisions_to_keep filter overrides the constant, and a post-type specific filter overrides both.

Page builders store their layout in their own way, so their pages may not behave like plain posts. Check the builder’s documentation for its own history feature.

Why do I only see one revision, or none, on an old page?
The site may have had revisions switched off, or a limit, when the page was edited. WordPress cannot recreate versions it never stored.
Does WordPress keep revisions forever?
By default it keeps all of them. Without a limit, the number grows with every update.

Limit the number of revisions

Add the limit to wp-config.php, for example to keep three revisions per post:

define( 'WP_POST_REVISIONS', 3 );

The constant takes these values:

  • true (default) or -1: store every revision.
  • false or 0: store no revisions, except the one autosave per post.
  • A number above 0: store that many revisions, plus one autosave per user. WordPress deletes the oldest ones when the post is updated again.

The limit takes effect per post the next time you update it. It does not clear the whole database at once. Developers who need a different limit per post type can use the wp_revisions_to_keep filter, or the post-type specific wp_{post_type}_revisions_to_keep filter.

Before you edit wp-config.php, keep a copy of the file. A syntax error in it takes the whole site down.

Delete old revisions safely

WordPress core offers a function to delete revisions, wp_delete_post_revision(), but no button for it. In practice you use a database cleanup plugin or custom code.

Make a full backup first, database and files. Deleting revisions removes rows from the posts table and cannot be undone. Then delete only revisions, not posts, and prefer deleting those older than a cutoff date or beyond the latest few per post.

Check one important page afterwards and open its revisions again. The current version and the revisions you meant to keep must still be there. If you also set a limit, WordPress keeps the list short from then on.

Revisions are part of your protection against mistakes. Do not delete all of them. Leave the latest versions of important pages in place, even if the database stays slightly larger.

Sources

More guides