Post revisions is a great feature that WordPress has to offer but for some users it might not be the best option. For users who have limited database space, or for users creating WordPress as a CMS where they don’t need autosave, they can simply disable Post Revisions feature in WordPress by following this tutorial. By reducing the database size, you can also speed up your site.
Open wp-config.php located in your WordPress root directory and add the following code:
define('AUTOSAVE_INTERVAL', 300 ); // seconds define('WP_POST_REVISIONS', false );
This code will disable all future revisions to be saved and it will also increase your autosave interval from 60 seconds to 300 seconds, so it means your post will be autosaving every 5 minute instead of every minute.
The above code, will not delete your past revisions that are already saved in your database. To delete all previous revisions, you will need to visit PHPMyAdmin and run the following SQL query.
DELETE FROM wp_posts WHERE post_type = "revision";
This should disable Post revisions and delete all previously saved post revisions stored in your Database.
Disclaimer: We are not suggesting that Post Revisions is a bad option. This tutorial is only for those who are in the situation where they need to reduce their database size.
Great article, simple and exactly what I needed.
Thank you, glad our guide was helpful
does it work with WP 4.9 and 5.1 or later?
Yes, this method should still work for those versions and later
Hi.
If I put the following code:
define(‘WP_POST_REVISIONS’, false);
It’ll stop any further revisions,even page revisions?
What the autosave does,occupies space in database?
Thank you
Tried with 4.5.2 and did not work, even i restart my xampp and tried after relogin, still getting revisions.
Its fine on my side using WordPress 4.5.3
it doesn’t work with wp 4.51…. anybody can help? thanks!
We checked, it still works with WordPress 4.5.1. Please recheck the code you entered. Or may be this code does not do what you are trying to do.
Awesome.. it’s work on latest wp.. thanks
Superb article — may be good to note that DELETE FROM wp_posts many not work if user changed table prefix (recommended) … and for user to change code to their table prefix
thanks guys
You’re right David. If you change the table prefix, you can try by using global $wpdb:
$wpdb->query($wpdb->prepare(“DELETE FROM $wpdb->posts WHERE post_type = %s”, ‘revision’));
Hi, seems like doesnt work for WordPress 3.8 ?
It works perfectly fine on WordPress 3.8
Will it work for Wordperss 3.7?
Yes.
Nice tips, instead of disabling revisions I’ll keep revision count 2 or 3. Thanks for this info. Great blog.
This is a very clever tip, I never thought of that. Thanks!
About the SQL query you have in your post:
DELETE FROM wp_posts WHERE post_type = “revision”;
For me it only works with single quotes around the term revision and not double quotes. (I have MySQL server version 5.1.30). I thought I mention this for others.
Thanks,
Boutros
really needed this one of my post had over 200 and i couldn’t figure out why. you guys are the best thanks a lot again
Wrong method of deleting post revisions
You got a better method? then please share.
Hey!
Good to see you responding
Here is the tutorial – http://blog.ashfame.com/2010/04/handling-wordpress-post-revisions-correctly/
I thought this is just too simple. Thanks for the heads up!
Nice post but for my part I prefer to use this plugin http://wordpress.org/extend/plugins/wp-optimize/
Agreed with Titifrim. With wp-optimize, there is option to “remove all post revision”. Another option: Clean marked Spam comments, Clean Unapproved comments, and Optimize database tables…
Thanks.
Our database badly needed that !
Deleted rows: 356 (Query took 0.0240 sec)
Yes, it does clog up the database tremendously fast! I have just been building this site – mostly over the weekend.
Thank you for this fix!
Came to this site via Six Revisions, great site, great tutorials.
Never thought that all those post revisions are saved in a database… the database must get bigger and bigger!
Can post revisions be deleted via the Dashboard? Would be useful for people like me who are OK with html and CSS but shy away from PHP coding.
Glad you made your way here from Six Revisions. Yes, it is possible. Simply use this plugin.
You can also use something like http://wordpress.org/extend/plugins/revision-control/ if you want a bit more control over just turning off revisions altogether.
@Dan… do you use this plugin yourself?
I need something like this because the instructions… “run the following SQL query” to delete revisions, scares me to death.
Will the plugin delete existing revisions?