Limiting WordPress Post Revisions

Perhaps more glamourous than Post Revisions?

Perhaps more glamourous than Post Revisions?

Going through my database the other day, as part of a general site tidy-up, I was quite surprised to find I had 1700+ post revisions stored in the wp_posts table relating to 80-odd actual Posts and Pages.

That sure is lot of “junk”, all thanks to my rather unnecessary habit of frequently clicking the Save Draft button whilst writing a new Post, and each time you Save Draft a Post Revision is stored in the database. This is all well and good, as it is clearly a good idea to be able to roll back to an earlier draft if necessary. However, once the Post or Page is published, it’s fairly unlikely that these Post Revisions will be needed again. Also, is it really necessary to create a new Post Revision each time? Hands up those of you who have ever rolled back to a Post Revision previous to the most recent one? Thought so, not many of you! :-)

This brief article shows you how to:

  • Configure WordPress to limit the number of saved Post Revisions to a specific number
  • Remove all Post Revisions from your database

Configure WordPress to limit the number of saved Post Revisions

Open up your wp-config.php file and add this code immediately above the “That’s all, stop editing! Happy blogging” line:

// Let's limit revisions to 3
define('WP_POST_REVISIONS', 3);

The number “3” tells WordPress to limit the number of Post Revisions to 3. Feel free to change this number to whatever you want (a positive integer only).

Don’t want any Post Revisions at all? Change the number to “0”, like this:

// Let's zap those revisions for good
define('WP_POST_REVISIONS', 0);
Post Revisions and Autosave: Disabling Post Revisions doesn’t disable Autosave – which is good news – and one Autosave is always saved in addition to the number of Post Revisions you’ve specified. Also, note that a Post Revision is only created when you click the Save Draft button. Once your configured number of Post Revisions is used up, WordPress automatically overwrites the oldest first.

Remove all Post Revisions from the database

Once you have reconfigured Post Revisions settings, as shown above, you might want to delete all the existing Post Revisions in your database so that you start with a clean slate.

Backup your database: If you don’t have much experience using phpMyAdmin, playing around with your database can be risky stuff. There’s no “undo”, so once you make a change it’s permanent, so backup your database before you begin!

Using phpMyAdmin, delete all Post Revisions in your wp_posts table using this SQL statement:

DELETE FROM wp_posts WHERE post_type = 'revision'

If you are using a custom table prefix (defined in your wp-config.php file), in the above SQL statement replace wp_posts with the actual table name.

Further reading

Revision Management from the Codex.


  1. Very useful tip, I too have a habit off saving as I go, so that I can preview the output lol

  2. Wow! Thanks for that.. I had just posted to the forum about how to get rid of the pesky Revisions and walla.. someone… sent me here… and it was exactly what I needed. I am on my way to clean up the whole mess…. Thank you very much.

  3. It’s useful article, there are many same article around the internet but you is the best because information along with explanation.

Leave a Comment


× 1 = two

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>