• Hello,

    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?
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • In your wp-config.php file, add this:

    define( ‘WP_POST_REVISIONS’, 10 );

    https://codex.www.ads-software.com/Revisions#Revision_Options

    Thread Starter utnalove

    (@utnalove)

    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?

    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.

    Thread Starter utnalove

    (@utnalove)

    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.

    Thanks

    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.

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to remove old revisions?’ is closed to new replies.