If you write your posts in a busy family environment as I do, you learn to hate WordPress post revisions.  Despite WordPress’s built in autosave feature, I like to save often, walk away, scream at the kids and then return to my writing.   By the time I’m finally satisfied with a post I’ve accumulated 20 revisions, thus creating a huge database clutter.  In my case I deleted almost 700 old post revisions following these instructions.  Let’s learn how.

The first step is to stop any new revisions from being created.  One method is to edit your wp-config.php file and add a line of code that says define(’WP_POST_REVISIONS’, false);The second method is to install a plugin called No Revisions.   It performs as advertised.  “Disables post revisions in WordPress 2.6 and on. Activate the plugin to disable them. Deactivate the plugin to re-enable them. Note that this does not delete any existing revisions, just stops WordPress from making any more.” 

Fantastic!  But how to delete those previous post revisions?  First thing to do is backup your current database “just in case”.  You should be doing this at least monthly on your own.  It prevents any tearful “my cat jumped on the keyboard and screwed up my database” excuses during the process.

1.  Log into your shared hosting account, Bluehost Hosting in my case.  Under the “Database Section” click on the phpMyAdmin icon as illustrated. phpmyadmin

2. The phpMYAdmin control panel should open in a separate window.  In the left sidebar you will see a list of databases, one for each WordPress installation.  Click on the name of the database that has revisions you want to delete. 

3. Then click the SQL tab for that database as shown. phpMyAdmin 

4. Inside the box that says “Run SQL query/queries on database” paste the following text and then click the “GO” button.  DELETE FROM wp_posts WHERE post_type = "revision";If you changed your WordPress database prefix, you must edit that line of code where it says “wp_posts”, but most installs use the default. A popup will ask if you really want to delete the revisions.  Click yes if you are confident of your copy and paste skills.

5. phpMyAdmin will respond with a message.  If it says “Error, table not found”, check your prefix.  If it says “Deleted rows: 0 (Query took 0.0007 sec)” then you already had revisions turned off.  If you are successful it will say something like “Deleted rows: 8 (Query took 0.0007 sec)”

6. While you are there, spend an extra 10 seconds and follow my directions to Optimize Your MySQL Database Tables and make your site run faster. 

This procedure deleted almost 700 old post revisions from Turnipofpower.com’s database.  Some of you may say “who cares”?   But if you ever had to upload a backup copy of a huge database, then you may understand.   Shouldn’t WordPress automatically delete revisions after a certain date?