Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

4 Answers

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
add comment

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
add comment

@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
add comment

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

http://wordpress.org/extend/plugins/revision-control/

share|improve this answer
2  
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
2  
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
add comment

Your Answer

 
discard

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.