How To Turn Off Post Revision In WordPress 2.6

One of the irritating feature for me in WordPress 2.6 is the post revision. I am the only author of my blog and hence this feature is useless to me.

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

In no time your wp_posts table will be filled up and the post ID will be huge.

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

1
define('WP_POST_REVISIONS', false);

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

1
2
3
4
5
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'

Be sure to backup your database first before performing any queries in phpMyAdmin.

*UPDATE* Auto Saves does not create a revision of the post.

*UPDATE 2* Updated SQL query from Andrei Neculau as the previous query does not delete from wp_postmeta and wp_term_relationships tables.

This entry was posted in WordPress and tagged , , . Bookmark the permalink.

150 Responses to How To Turn Off Post Revision In WordPress 2.6

  1. Thank you. You’re a life saver… Thanks again for proving sql query to delete the old revision posts. :)

  2. Pingback: wpSnap Site Reboot » HeadsetOptions

  3. aflie says:

    hi, lester
    the code within your post seems beautiful, how can I do that? use a code highlight plugins or manually edit css file?

  4. aflie says:

    thanks, It is a nice plugin!

  5. Thanks a ton for your help.
    I went mad afer upgrading to WP 2.6.
    I added define (‘WP_POST_REVISIONS’, 0); in my WP-CONFIG file but I am still seeing the autosave functionality.
    Is there any other trick ?

  6. Lester Chan says:

    it will still autosave, but it will not create the revisions

  7. Stijn says:

    Thanks a lot, Lester! Disabling and then deleting all those revisions cut my db size in half!

  8. Terje says:

    Will it be the same if you just change the WP_POST_REVISIONS in wp-settings.php from true to false?

  9. Lester Chan says:

    It is not recommended to touch the core files as you will lose them if you upgrade

  10. ardiweb says:

    I really need this post. I don’t know about this feature, usefull or useless..
    Many thanks….

  11. Pingback: Cara Mematikan Fitur Post Revision di WordPress 2.6 ke atas » Ardi's Personal Weblog

  12. Pingback: It’s My Life » wordpress autosave??????

  13. Jimbo says:

    What is the difference to this code?

    DELETE FROM wp_posts WHERE post_type = “revision”;

    which I found here?

    http://www.mydigitallife.info/2008/07/22/how-to-delete-existing-wordpress-post-revisions-storedsaved/

  14. Lester Chan says:

    That code will only delete away the revisions but not the custom meta along with the revision.

  15. Jimbo says:

    Lester Chan,

    Thanks but how do I know if my posts have any custom meta data or not? E.g. what other data is being stored in the ofter tables?

    Thanks,

    Jimbo

  16. Lester Chan says:

    There is no way of knowing unless you know the IDs of the post.

  17. Poker Radio says:

    Thanks! Just what I have been looking for!

  18. Jurij says:

    Dear Lester,

    THANK YOU VERY MUCH! I fullfill e-shop (of course without database backup on) and almost loose a 1 week work with “smart” revision function.

    THANK YOU AGAIN! Jurij Cvikl (Linkedln)

  19. Fred says:

    THANK YOU..I mean it..
    I just wonder why the wp core devs did not test this better. meta values are a core feature and the issue should have been plain to them before the release. Upgrading wp every heartbeat already is a pain (I have a heavily modified template and many customized features), but encountering these issues really makes me regret upgrading.
    Again, thank you

  20. heinz says:

    Hi mate,
    thanx for the explanation. It helped me a lot!

  21. Pingback: WordPress 2.6 Presents The Matrix Easter Egg - Walker News

  22. Wow very useful post. I was not even aware of the fact that post revisions are taking up huge db space. I iwsh we had a plugin for it rather than modify the config file which even though easy requires more manual work.

  23. Bob says:

    A lifesaver! My problem was a little more serious than most in that I’m using an ECOMMERCE plugin for my client’s site that kept on attaching itself to a revision of the main products page. This fixed it. Thanks for a very helpful post.

  24. Pdesign says:

    Nice plugin! Thank for sharing

  25. Pingback: ??????WordPress mu?PostRevisions?autosave?? = ???? ????

  26. Jonnya says:

    Remember guys – you can do this with the newly updated for WordPress 2.7 WP-CMS Post Control plugin over at http://wordpress.org/extend/plugins/wp-cms-post-control/

    Whilst WordPress 2.7 gives some interface control to the write post and page panels, this plugin gives you COMPLETE control, also allowing you to turn off post revisions, auto save and even force the uploader back to the old browser one instead of Flash (this solves a-lot of problems for people).

    This update also covers all the new WordPress 2.7 interface features – for instance being able to hide the favorites dropdown in the header of the admin panel.

  27. FeRHaD says:

    Thanks. Nice trick.

  28. Emanuil says:

    Thanks! This is really helpful.