Turn Off and Delete WordPress Post Revisions

So those post revisions WordPress is storing are starting to build up and you want to clean up… Maybe you want to turn off the post revisions… but you don’t know how, well read the following and you should be set. Please keep in mind I am NOT responsible for anything you might try on your own blog. These instructions are for WordPress 2.7.0, settings maybe changed in newer versions.

I used MySQL GUI tools to do the following however you can do it from the command line. I normally do it from the command line but sometimes GUI can just save time…

— CHECK THE AMMOUNT OF ROWS IN YOUR WP_POSTS TABLE
SELECT * FROM wp_posts WHERE post_type = “revision”;

— CREATE A BACKUP TABLE OF WP_POSTS (SHOULD DATE THE BAK TABLE YYYYMMMDD)
CREATE TABLE wp_posts_bak LIKE wp_posts;

— COPY THE ORIGINAL WP_POSTS INTO THE NEW BACKUP TABLE WP_POSTS_BAK (SHOULD DATE THE BAK TABLE YYYYMMMDD)
INSERT wp_posts_bak SELECT * FROM wp_posts;

— CONFIRM THE AMMOUNT OF ROWS IN WP_POSTS_BAK MATCH THE ROWS IN WP_POSTS
SELECT * FROM wp_posts_bak WHERE post_type = “revision”;

— DELETE THE DATA FROM WP_POSTS WHERE POST_TYPE=”REVISIONS”
DELETE FROM wp_posts WHERE post_type = “revision”;

— COMMIT YOUR DATABASE CHANGES (POINT OF NO RETURN – you can do a “ROLLBACK;” if your unsure)
COMMIT;

In order to stop WordPress from saving post revisions you will need to add the following line of code to the “wp-config.php” file. I recommend backing up the “wp-config.php” file before making any modifications. The method I am showing here assumes that you have shell/terminal or command line access. If you don’t have access to a shell/terminal or command line you can do it through an FTP program.

— BACKUP YOUR WORDPRESS CONFIG FILE BEFORE EDITING
cp -pr wp-config.php wp-config.php.ORIG (or by date wp-config.php_YYYYMMMDD)

— TURN OFF REVISIONS IN WORDPRESS IN wp-config.php by adding the following line
define(‘WP_POST_REVISIONS’, false);

Leave a Reply

Your email address will not be published. Required fields are marked *

*