Disable or limit WordPress Post revisions

Many WordPress page revisions
Gonna limit them

In latest WordPress versions ( since 2.6.) along other cool features  one really useful functionality is Post revisions (with that also Page revisions). This great feature automatically saves article ( or page), so you don’t have to worry about  loosing your work, when internet suddenly dissapears or computer crashes. Post revisions also means that you can see what have  you written earlier (maybe yesterday you had more brilliant thoughts, so you can use previously saved version of post). More about Revisions you can read in official WordPress page  http://codex.wordpress.org/Revision_Management, in this article I’ll focus on how to limit Post revisions and delete existing revisions.

Maybe something changes, but right now WordPress allows unlimited number of post revisions. What that means, isn’t hard to figure out:

  • If you write medium or long post within WordPress ‘Add post’ form, that will result in huge number of post revisions. Because time by time WordPress saves current content of post, thus longer you write = more revisions.
  • If you have post/page, that regularly needs to be updated, again – you will have many revisions.

Many revisions looks messy under Add Post or Edit Post form, it makes your database bigger, so lets deal with that.

Disable or limit Post revisions using wp-config.php:

To disable Post revisions simply open wp-config.php (file is located in root of WordPress installation) in you text editor,  add this
define('WP_POST_REVISIONS', false );
to the end of file.
To limit revisions, add
define('WP_POST_REVISIONS', 3);
where instead of 3 you write maximum number of Post revisions per post/page.

More about editing wp-config read in official WordPress help page

More control over post revisions

Manage post revisions
Revision control plugin

There is Free plugin Revision control. Set maximum number of revisions, optionally – set Revision Range, so you can set specific count of maximum revisions for each post. Of course, if you don’t set then default will be used. Lately I’ve been using  this plugin for all WordPress sites and there haven’t been any complaints.

Delete existing revisions.

Open phmyadmin, go to SQL options and run this query:
DELETE FROM wp_posts WHERE post_type = "revision";

This query deletes all post revisions and page revisions. You can extend query by deleting revisions within specific time range. For example, delete revisions before 1st of march 2012

DELETE FROM wp_posts WHERE post_type = "revision" AND post_modified < "2012-03-01 00:00:00";

So in summary – Post revisions are great, but you ought to limit number of revisions.You can do that either by editing wp-config.php file or using plugin Revision control. Anyways, hope this article helped and  happy WordPress’ing!