5

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

8

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

1
  • I don't think that will remove the old revisions that already exist, though.
    – Ian Dunn
    Mar 7 '12 at 1:55
4

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

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

3
  • 2
    I really don't see the need for using (yet another) a plugin for something so trivially simple
    – user2015
    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
2

@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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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