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:

define('WP_POST_REVISIONS', false);

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'  

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.

*UPDATE 3* There is a proper way of cleaning up Post Revisions as mentioned by kitchin in Deleting Post Revisions: do NOT use the a,b,c JOIN code you see everywhere. I like his method more than the SQL query above.

1 Star2 Stars3 Stars4 Stars5 Stars (178 votes, average: 4.18 out of 5)

150 thoughts on “How To Turn Off Post Revision In WordPress 2.6”

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

  2. 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 ?

  3. 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

  4. 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)

  5. 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

  6. 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.

  7. 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.

  8. 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.

Comments are closed.