» Managing Post and Page Revisions in WordPress
Posted: May 6th, 2009 | Sammy Russo | My Favorite Plugins, WordPress Tips & Tricks
With the release of WordPress 2.6 a new feature was added that tracks and retains all previous versions or revisons to WordPress Posts and Pages. Many think this is a great feature and can be very useful. In the building of California Whitewater I used the revision feature several times to roll back to a previous version.
A Valid Problem With Post Revisions
If you sift through the WordPress Support Forum you will find many WordPress users griping about the revison feature because it tracks all revisions. If you have a 100 posts and you edit each post 2 or 3 times you will get an additional 200 – 300 records in your MySQL database. For bigger sites or blogs do the math. This makes for an unruly database size.
Being that California Whitewater took us several months to build and with 4 people making content edits over the course of 4 months we had an extra 2600 records of revisons in the database. We build the site in a development space and when it was time to move the site to the live server I couldn’t move the database in one shot… I had to split it into 4 parts, do a find and replace on each part to update the URL and image paths and then move the DB.
Before moving I did look through the forums for help on how to clean up the database but I wasn’t comfortable with doing a global delete of all revisions in the MySQL database to reduce the size of the DB.
Deleting Your Post Revisions
Now that site is live and all is good, I went back to the development space for California Whitewater and ran this MySQL command to clear out all the revisions. I did it on the dev site to test the process and ensure I wouldn’t break anything on the live site if something were to go very wrong.
Step 1. Back Up Your Database.
- You can follow the steps outlined here in Simple Maintenance to run a backup.
- You can also install a WP-Plugin like WP-DB-Backup or try anyone of the Backup Tools.
- Open PHP My Admin
- Select the database you wish to clean up
- Click the SQL Tab in the top horizontal navigation
- Copy and Paste this Command:
DELETE FROM wpposts WHERE posttype = "revision";
Use a Post Revision Plugin
There a several Post Revision Plugins in the WordPress Extend section. The one I downloaded “Revision Control” is great and has become part of my personal collection of plugins I use on all sites.
What I like about Revision Control is that you can enable or disable revisions on global bases as well as set the number of revisions to keep. I set Revision Control to retain the last 5 versions of both pages and posts. You can also control the revision process on a page-by-page or post-by-post basis.
There you have it.. an easy way to delete post revisions from the database as well as a great plugin to control revisions.
** I was googling for a good way to manage revisions (more than a 1,000) both current and future and this post put all the tools together in one easy to read place -Sable