3 Ways To Control Post Revisions In WordPress

by Nabeel Ahmed · 10 comments

This is a guest post by Nabeel Ahmed from Mushive.com who is sharing with us in this post, a wordpress tutorial to control wordpress post revisions.

WordPress by default creates revisions of your posts automatically. Whenever you save a page or post, the older version is retained so that you can revert it back at any time.

Sure this feature is handy at times but it is understandable that every revision would take its own space in the database. This would mean nothing for a few revisions but as your blog grows bigger & each post or page has multiple revisions; it shows its effect.

This makes it necessary to do some housekeeping & gain control over revision by removing older revisions to free up disk space and ease MySQL’s processing burden. This also has effect on the speed of your blog.

post revisions

Here I am sharing 3 ways in which you can keep a check on post revisions & keep them under control or disable post revisions completely. (But before we begin I advise you to BACKUP YOUR DATABASE):

1. Remove Old Revisions

I am going to repeat BACKUP YOUR DATABASE because in this step we are about to run SQL command directly on your MySQL tables & one tiny slip can break your wordpress installation. First, you need to find your WordPress table prefix which is specified in the following line of wp-config.php:

$table_prefix  = ‘wp_’;

wp_ is the default table prefix but it may have been changed as a measure of added security. We’ll assume wp_ has been specified in the following code.

To delete all revisions for all pages and posts, start a MySQL administration tool such as phpMyAdmin and run the following SQL statement:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = ‘revision’;

(Remember to change all table references from “wp_” to your table prefix if necessary.)

If that’s a little too severe, you could remove all revisions prior to a specific date, e.g. the following statement will remove all revisions except for those made after January 1, 2010:

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = ‘revision’
AND a.post_date < ‘2010-01-01’;

2. Limit or Disable Post Revisions

Add the following statement to your WordPress wp-config.php file to permanently disable post revisions:

define(‘WP_POST_REVISIONS’, false);

The value can be set to ‘true’ to re-enable revisions.

Alternatively, you can use a positive integer to limit the number of permitted revisions, e.g.

define(‘WP_POST_REVISIONS’, 5);

This will create a maximum of 5 revisions per post, plus one for auto-saving purposes. Older revisions will be automatically deleted.

3. Use WordPress Plugins

If this all sounds a little too scary, than there are a number of WordPress plugins offering revision control.

Do you have any further tips for controlling WordPress revisions? Share it with us by commenting below…


Top 10 Search Terms:

• wordpress revision control • revisions • wordpress 3 revisions

About Nabeel Ahmed

Nabeel Ahmed is an enthusiastic new blogger who writes about Technology, Wordpress & Social Media on Mushive. You can also follow him on twitter @mushive

has written 1 superb article(s) on this blog

Visit my website →

Dan Keller July 11, 2010 at 12:40 am

I never knew it was possible to stop the automatic revisions. I think I will look into the plugin, the coding part does look a bit scary for me.

imran July 11, 2010 at 2:15 am

Good. I did not know that WP keeps the older versions of posts too 🙂 My blog is not so much populated, but i will surely use this method, when i need.

Mike July 11, 2010 at 3:57 am

This is interesting. I didn’t even know my revisions were stored. Currently my blog is till growing but I can see how this could eventually become an issue.

Colleen July 11, 2010 at 5:46 am

I like #3 the best. Controlling post revisions with a plugin is certainly easier for someone (me) who does not want to mess with the code. 🙂

Febap Liew July 11, 2010 at 10:37 am

hey nabeel,
inevitably, i believe this an essential part of as you mentioned ‘housekeeping’ to improve the performance of your wordpress blog.
but alas, all this sort of technical applications can really drive me ‘nuts’ . i don’t mind configuring it out of sort here and there but if i could help it, i try not to get involve in this sort of techies appliances. =P nonetheless, i am sure as you mentioned that there are inevitable many plugins for people like me. lol
but hey, you have shed me some lights to another set of possibilities in upkeeping my wordpress blog. will be sure to look into this with plugins available of course.
as they always say, you can have the best looking wordpress blog but without preference performance that suits the readers’s needs, your blog is as dead as it could be. =)
cheers
have a nice day.

Derek July 11, 2010 at 10:52 am

I like the tips you mentioned. Although i do not use any of them, it’s good to make backups of your wordpress blog including mysql database a min. of once a week. I had a bad plugin break a table in my mysql database and lost 2 weeks of content. At that time i did backups once every 2 weeks. Now i backup 2 times a week. Better safe then loose everything. Us bloggers sometimes spend hours on our blogs writing posts or making small changes.

Ok, back to the blog post itself. The plugin i use that clears the post revisions is this one. http://wordpress.org/extend/plugins/wp-cleanup/

It does a few other things also. This works great with wordpress 3.0

Daniel Sharkov July 12, 2010 at 12:30 am

Being able to use an older version of the same post is definitely a great Wordpress feature, which as far as I know is not possible in Blogspot blogs. That is yet another reason for me to move to the Wordpress platform.

Shawn July 14, 2010 at 6:54 pm

Nabeel, this is quite a timely post, now that G has decided to include page speed in its ranking algo,

All my blogs are small and very little revisions, but as they grow i will keep these code snippets in mind

Shawn,

Jack July 29, 2010 at 5:15 pm

For some reason, some of my posts keep getting blanked out after upgrading to Wordpress 3.0. Even today, an old post which was posted on 15th July turned out to be a blank. Something’s wrong with wordpress I guess.

Revisions has saved me more than once. I think I’ll keep them on, for now…

Usama September 30, 2010 at 5:46 am

Didn’t even know revisions were being stored. This is very useful.
Thanks.

Previous post:

Next post:



whos.amung.us