WordPress has a function titled “Post Revisions” that when each time you save draft or publish a post or page and saves a revision copy of that post or page. It was introduced to help wordpress bloggers to keep revisions of post and restore to previous revisions anytime. This Feature can take up a huge chunk of database space however if you have a site that has a lot of articles, in this post we will show you several methods of how to disable the “Post Revisions” Feature and deleted stored revision posts from your database.
So whats the main benefit when disabling “Post Revisions” within wordpress?. Here at SocialCMSBuzz we had a database size of around 28MB, after disabling and deleting our “Post Revisions” this number dropped to around 8MB thats 20MB of a saving in MYSQL space within your wordpress database.
Method One – Getting Hands Dirty
The first method we will show you requires you to edit the wp-config.php to disable “Post Revisions” and also run an SQL query from within phpmyadmin to delete any stored “revision” posts from your wordpress database. There are several options we can use when disabling post revisions, read more about them here Revision Management.
To simply disable WordPress posts revisions completely we have to edit the wp-config.php file found in you wordpress root directory.
Copy and Paste the code below into your wp-config file, this will disable post revisions.
Next we need to run an SQL query from within PhpMyAdmin to delete the “Post Revisions” from your database. Remember to backup your database first as you always should before running any queries.
Run this query below
DELETE FROM wp_posts WHERE post_type = "revision";
Another query you could try is an older one from Lester Chan which deletes “Post Revision” data from wp_postmeta and wp_term_relationships tables also.
1 2 3 4 5
DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'
Method Two – Use A Plugin
There are also a few plugins available to preform this task if you wish to use these we have listed them below for you.
Revision Control is a plugin for WordPress 2.8+ which gives the user more control over the Post/Page Revisions.
The plugin allows the user to set a blog-global setting (Settings -> Revisions) for pages/posts to enable/disable/limit the number of revisions which are saved for the page/post. The user may change this setting on a per-page/post basis from the Revisions Meta box.
The plugin also allows the deletion of specific revisions via the Revisions post metabox.
Let us know if you use any of these methods, how you get on and if you saved any database size.