WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How does one reduce the number of stored revision (e.g. 5 max) for post types that support revisions?

share|improve this question
up vote 8 down vote accepted

add to your wp-config.php file the following line:

// set max post revisions    
define('WP_POST_REVISIONS', 5);

source: http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions

share|improve this answer
I don't think that will remove the old revisions that already exist, though. – Ian Dunn Mar 7 '12 at 1:55

Just use the plugin. Simpler than screwing around with it, and provides more control.


share|improve this answer
I really don't see the need for using (yet another) a plugin for something so trivially simple – Piet Apr 15 '11 at 15:06
Plugins are faster, easier to work with, don't require ridiculous hacks, and often well maintained if you pick the right ones. Since Revision Control is maintained by dd32 (a core team member), then you know it will work significantly into the future. – Otto Apr 15 '11 at 18:00
In this case, Revision Control provides an easy way to change the number of revisions, automatically will clean up old revisions for you (without running manual SQL queries), lets you delete specific revisions, and allows the number of revisions to be adjusted on a per-post basis. All without editing any files. – Otto Apr 15 '11 at 18:06

@Piet's answer is the best, but some sql code to remove all old revisions older than 28 days:

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'
AND a.post_date < DATE_ADD(NOW(), INTERVAL -28 DAY);

SQL and PHP code (for diffrent WP_PREFIX than "wp_") iworks_revisions.zip

share|improve this answer

I'm not sure of an automatic way but there is always running the MySQL Query DELETE FROM wp_posts WHERE post_type = "revision" (source) I haven't done it but I'm sure it works. I'd look for a plugin by now there has to be something.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.