How to Delete Post Revisions in WordPress

How can you delete post revisions in WordPress blogs? Post revision is a cool way in which WordPress autosaves your posts while you type. This helps to recover posts should your browser crash, or internet crash, and you can always restore an older version of the post. But Post revisions tend to pile up in your database.

We use Vaultpress WordPress backup and its stats informed us that we had over 4000+ posts and 8000+ post revisions! The number of post revisions is double the number of posts! No wonder the database file size is growing so fast. Every post we edit keeps accumulating post revisions. If there are frequently edited posts, the revision can be a large number.

Optimize Post Revisions

Of course you can stop post revisions by adding the following to wp-config.php (in root of your WordPress installation)

define('WP_POST_REVISIONS', false);

But post revisions have really helped me recover crashed posts, so I want to continue using them. So I add these to wp-config.php instead.

define('WP_POST_REVISIONS', 3);
define( 'AUTOSAVE_INTERVAL', 120);

This saves only the latest 3 post revisions of any article (note false is replaced by 3, you can add a different value if you like), so multiple edits will not pile up these post revisions. Next I increased the autosave interval to 120 seconds (default is 60 seconds). So this lets me continue using post revision with decreased saves and only latest saves. But this does not delete my 8000+ useless post revisons over 3-4 years old, which I no longer need.

Delete Post Revisions

Download the Delete Post Revisions Plugin and it will delete all the post revision there are. This is how the admin panel of the plugin looks like. We did not click the check box as there were too many revisions. There is only 1 button and that does the job.

delete-post-revision

It took the plugin over 20 minutes as we had over 8000 post revisions and we had to repeat 3 times till we got the message that no post revisions could be detected.

deleted revisions

So now our databases is much cleaner and lighter as we have deleted unnecessary post revisions and have modified good settings for post revisions to work well in future.

Share with friends

4
Leave a Reply

avatar
4 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
4 Comment authors
Anushka SharmaTech CratesRealTimeTricksPankaj Gupta Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Pankaj Gupta
Pankaj Gupta

Yes, I am using this plugin and I run it once in a month to delete all previous revisions.

RealTimeTricks
RealTimeTricks

Amazing, after reading this post i got to know about ‘Post Revision. Before it, i have no idea about what Post Revision is for. :)

Tech Crates
Tech Crates

Wasn’t aware of the delete post revisions plugin … will be of great use to me as I keep on editing the posts for some or other reason

Anushka Sharma
Anushka Sharma

i have deleted all the revisions….