How to remove old revisions? (7 posts)

  1. utnalove
    Posted 1 year ago #


    my database is huge. There are hundreds of posts with 60+ revisions.
    Is there a way or plugin that allows me to:

    Delete all the revisions,BUT the last 10?

    I can see that all the plugins out there delete only the old revisions based on the age. I need to leave the newest 10 revisions. No matter how old they are.

    Any hints?

  2. In your wp-config.php file, add this:

    define( 'WP_POST_REVISIONS', 10 );


  3. utnalove
    Posted 1 year ago #

    From my understanding what you suggest will limit the revisions to 10, only for new posts.

    It will not bulk delete the >10 revisions for all the already publishes posts.

    Or does it work like this?

  4. As per the content that I'd linked you to:

    (int) > 0: store that many revisions (+1 autosave) per post. Old revisions are automatically deleted.

    Try it. I'm not sure if it will purge them all right away, or only when you save the post.

  5. utnalove
    Posted 1 year ago #

    Ok, thanks. I'm going to add that to the config file.

    If anybody else knows some more concretes, please feel free to share your knowledge. I'll be glad for that.


  6. ssiruguri
    Posted 1 year ago #

    I'd confirm George's guess that you have to update a post for the number of revisions to be updated. L119 (WP3.7.1) onwards in the function wp_save_post_revisions in wp-includes/revisions.php says

    $revisions_to_keep = wp_revisions_to_keep( $post );

    if ( $revisions_to_keep < 0 )
    return $return;

    That's where the config variable is checked. Plugin filters are applied after the variable is checked, so plugins will override that value.

  7. ADUpchurch
    Posted 1 year ago #

    I use the WP-Optimize plugin, it takes care of that for me.

Topic Closed

This topic has been closed to new replies.

About this Topic