Skip to content

Post revisions

A revision is a stored copy of a post or page as it was at an earlier save. WordPress records one for each saved draft or published update, keeps every one by default, and lets you compare and restore them. An autosave is a separate, single copy per user.

By
WP Ministry
Published

In short

  • A revision is made each time you save a draft or update a post. An autosave is one copy per user, replaced each time.
  • By default WordPress keeps every revision. `define( 'WP_POST_REVISIONS', 10 );` in wp-config.php keeps ten per post.
  • To restore one, open the post, open the Settings sidebar and select the number beside Revisions.

A revision is a copy of a post or page as it stood at one save. WordPress's documentation says the revisions system "stores a record of each saved draft or published update". You can step back through those copies, see what changed between them, and restore one. By default WordPress tracks changes to the title, author, content and excerpt.

Revisions are rows in the database's posts table, stored as children of the post they belong to, with the post type revision.

Revisions and autosaves

  • A revision is made when you save a draft or update a published post. It is kept.
  • An autosave is made by the editor while you work. There is at most one per user for a post, and each new one overwrites the last. It never overwrites the published content. If the browser crashes, WordPress offers the autosave back when you next open the post.

How often the editor autosaves is where the sources disagree. WordPress's glossary says changes are saved "every 2 minutes". The wp-config.php documentation says the default is 60 seconds, and the current source, default-constants.php, sets AUTOSAVE_INTERVAL to one minute. The source is what a site runs.

Where you meet it

In the editor. Open the Settings sidebar and stay on the Post or Page tab. A row named "Revisions" shows a count. Select the number. Since WordPress 7.0 that opens the revisions screen: a slider across the top, a list of saved revisions under a "Revision" tab, and two buttons, "Exit" and "Restore". Move the slider to the version you want and select "Restore".

The link "Open classic revisions screen" leads to the older view, where the button reads "Restore This Revision". In WordPress 6.9 and earlier, the number opens that view directly.

In wp-config.php. Two constants control the feature.

ConstantDefaultWhat you can set
WP_POST_REVISIONStrue: every revision is keptA number keeps that many per post, plus one autosave per user. Older ones are deleted when the post is next updated. false or 0 stores none, apart from the autosave.
AUTOSAVE_INTERVAL60 secondsThe number of seconds between autosaves.

The wp-config.php generator writes the revisions line for you.

What goes wrong

  • The database grows. With no limit, a page edited hundreds of times carries hundreds of rows, and WordPress has no screen for deleting them. How to clean up and optimize a WordPress database shows how to count them, remove them and cap them, and what that does and does not do for speed.
  • Revisions were switched off. With WP_POST_REVISIONS set to false, there is no earlier version to return to after a bad edit. A number is the safer setting.
  • The limit seems to do nothing. Setting a number does not trim what is already stored. A post's older revisions go the next time that post is updated.

The WordPress maintenance checklist says when revisions are worth clearing.

How to look at yours

With WP-CLI, this prints how many revisions the site holds:

bash
wp post list --post_type=revision --format=count

Common questions

How many revisions does WordPress keep?

Every one, unless told otherwise. The developer reference says that "an infinite number of revisions are kept" by default. Set WP_POST_REVISIONS to a number in wp-config.php to keep that many for each post.

Is an autosave a revision?

It is stored as a special type of revision, but it behaves differently. There is one per user for a post, it is overwritten each time, and it does not change the published post. In the list of revisions it carries the label "Autosave".

Can I get back a revision I deleted?

Not from WordPress. A deleted revision is a deleted database row. It comes back only from a backup made beforehand.

Not sure what is wrong?

Tell us what you see. We reply with the cause and a fixed quote, and the diagnosis is free.