WordPress.org

Ready to get started?Download WordPress

Forums

How to remove old revisions? (7 posts)

  1. utnalove
    Member
    Posted 5 months ago #

    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

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

    define( 'WP_POST_REVISIONS', 10 );

    http://codex.wordpress.org/Revisions#Revision_Options

  3. utnalove
    Member
    Posted 5 months 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
    Member
    Posted 5 months 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.

    Thanks

  6. ssiruguri
    Member
    Posted 4 months 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
    Member
    Posted 4 months ago #

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

Reply

You must log in to post.

About this Topic

Tags