How does one reduce the number of stored revisions?

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

Related posts

Leave a Reply

4 comments

  1. @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

  2. 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.