How To Turn Off Post Revision In WordPress 3

with 6 Comments

One of the “features” that irritate and frustrate me in learning WordPress 3, is the post revision. I am the one and only author of my blog and hence this feature is useless to me, actually less than worthless, it is a pain!

Just in case you are wondering how post revision works, whenever a post is edited, a new database row will be created in wp_posts table. Hence if your posts or pages get edited 10-20 times, you will have 10-20 new rows in wp_posts table.

Your wp_posts table will be filled up and the post ID will be huge in no time.

Looking around I found these suggestions about what to do…

To turn off this feature, add this following code to wp-config.php

define ('WP_POST_REVISIONS', false) ;

Or You can use: (it does the same thing)

define ('WP_POST_REVISIONS', 0) ;

This will stop NEW revisions.

To delete old saved revisions I found suggestions like this one from Lester Chan and Andrei Neculau

You can also delete all post revisions by running this query in phpMyAdmin:

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'

I don’t know about you but I am not too happy making manual database changes. I wanted something much simpler and safer too. Here is what I figured out!

This code:

define ('WP_POST_REVISIONS', 0) ;

Actually means do not keep any revisions! But take not of the “0” (zero). You can insert something there like 5 and this will keep only the last five revisions and delete the rest! Like this…

define ('WP_POST_REVISIONS', 5) ;

I figured it would really help me a lot if I only kept 2 revisions and so I added this code to wp-config.php

define ('WP_POST_REVISIONS', 2) ;

To my delight, my test post dropped from 12 revisions to just 2! But that is counting the CURRENT revision that I am serving. Wow! It was insighting!

Suddenly I realized that if I set it to one, it would delete ALL revisions each time I updated a post! Keeping only the final revision! Just what I wanted! So here is my complete and total change…

To wp-config.php add:

define ('WP_POST_REVISIONS', 1) ;

No other changes are needed. It will now delete all revisions except the last of current revision you are serving on your blog – and your database size may shrink every time you update a post with many revisions! If you use WordPress and edit online, that could be huge!


Codifically Yours,


6 Responses

  1. Katie
    | Reply

    Thank you! I also wasn’t looking forward to messing with the database to get rid of the old revisions. 🙂

    • Lan
      | Reply

      Hey Katie, I would like to thank you for writing the only comment, out of hundreds, that actually addressed this post! The rest I consider as spam! The funny thing is the “messing with the database” would actually be my first choice! I am a database expert and have more years of “messing” than most programmers have lived!

      Nonetheless, my goal on this site is to write for my wife and my kids. Something simple and useful they can do easily. So I am glad it helped you too!

      Soon I will have to write a series on what is spam and easy ways to deal with it! Good luck Katie!

  2. Juin
    | Reply

    Thanks for your safe solution.

    After setting WP_POST_REVISIONS to 0,
    I don’t see any revision info in the WordPress Edit Page, however, there are still two old revisions with two IDs still left for each page in the database table WP_POST_REVISIONS.

    I am reluctant to remove those extra rows manually. Could you verify my finding? Thanks.

    • Lan
      | Reply

      Juin, one of those “revisions is likely your current post. The other is likely your autosave.

      I did not try 0 and I personally do not deleting manually is a good idea.

      In a lot of PHP “0” actually means “false” or “off” so in that case zero may mean allow as many revisions as possible!

  3. Juin
    | Reply

    Sorry, the database table is WP_POSTS.

  4. […] are a lot of articles and posts available that show you how to disable the Post Revisions feature in […]

Leave a Reply