Delete WordPress Post Revisions

  • 1 Comment
  •       367 words

WordPress has a function called post revisions that will save a copy of a post or page every time you press the save draft button, this was introduced to help restore previous versions of posts/pages incase the user makes a mistake. As you can imagine, this can be very handy, one that I am sure we have all used before.

If you haven’t heard of this feature before then scroll down either a page or post, in the back-end, so long as you haven’t reordered any of the elements using the drag and drop feature, then post revisions should be five boxes below the content area.

I know I’m guilty of pressing the save button every couple of minutes due to the various computer crashes I’ve had throughout my life, so I know that I will have a lot of revisions for pages and posts. However, one thing that you may not know about this feature is the huge amount of information/duplicate content that it will add to your database. So how do you get rid of all these revisions?

There are several different ways you can tackle this:

Turn off post revisions

If you do not need this feature you can turn it off by adding the following code to your wp-config.php file define(‘WP_POST_REVISIONS’, false); however I wouldn’t really recommend this as it’s always good practice to have back-ups of your work.

Deleting older revisions

If your a dab hand within the confides of phpMyAdmin then you could execute this query DELETE FROM wp_posts WHERE post_type = “revision”;. This will delete all instances of revision from your database but please take a copy of your database before you go about doing something like this.

Use a plugin

One final option would be to install the WordPress revision control plugin which gives users more control over the revisions. The plugin allows the user to set a global setting for pages and posts where you can enable, disable and limit the number of revisions which are saved for each page and post.

If you liked this article then please feel free to Tweet it
  • Who I am

    My name is Jack Osborne and I am a Glasgow–based designer and writer. You should follow me on Twitter.

One Response to “Delete WordPress Post Revisions”

  1. Robbie says:

    The fact that this feature will inevitably fill the database with (in my case, mostly redundant) content hadn’t even occurred to me, so cheers. I’m still paranoid enough about browser crashes to usually draft posts quickly in Things before going near WP!