When writing a post, I don’t often write it all in one go, then before I publish it, I save it and preview it, generally more than once.
WordPress has 2 Great ( or not ) features, Auto-Save, and Revisions.
When writing my last post Clean Dynamic Directory Listing with PHP I have some example code wrapped in <pre> tags and WordPress auto-validates code, which is a handy feature, but not here where I was trying to enter my example.
So after several saves, and eventually getting in to my mySQL database to fix it and seeing that for hat this time only having 22 posts/pages, my database shows 199 records!
To get directly to the point, some handy shortcut links:
Disable Auto-Saving
Disable Saving Revisions
Final code
Cleaning up the Database
Disable WordPress Auto-Saving my Posts!
So, I looked in to it and found people hacking their wp-ajax.php and post.php and thought, Oh Hell No! That is going to break every time I update WP, and who knows what else.
So.. a little bit of digging in to my code and found what I needed.
Open your WordPress Config File:
/wp-config.php
And after the first set of functions I added this line:
12 | define( 'AUTOSAVE_INTERVAL', 900 ); |
By Default this value is set to 60 (seconds), 600 equals 1 Hour, 900 equals 1 1/2 hours, you can go higher, but i figure 1 1/2 hours in my case is good.
Disable WordPress Revisions!
I dont need or want 10 revisions of my posts, I am the only one editing them and this is not a Wiki! One Post, One Revision!
In the WordPress Config File:
/wp-config.php
And after the first set of functions I added this line:
13 | define( 'WP_POST_REVISIONS', 0 ); |
By Default this value is On (1), but turn it off by setting it to Off (0) ( Zero ).
Sheldons revised WP-CONFIG.PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 | < ?php // ** MySQL settings ** // define('DB_NAME', '*database*'); // The name of the database define('DB_USER', '*username*'); // Your MySQL username define('DB_PASSWORD', '*password*'); // ...and password define('DB_HOST', 'localhost'); // 99% chance you won't need to change this value define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); // TURN OFF AUTO-SAVE AND SAVING REVISIONS // THEY ARE MAKING A GOOD AWEFL MESS OF MY DB AND MESSING UP SETTINGS WHEN WRITING! define( 'AUTOSAVE_INTERVAL', 600 ); // 60= 1 HOUR. define ('WP_POST_REVISIONS', 0); // TURN OFF POST REVISIONS. |
Cleaning up those extra 175 records!
Ok, I have disabled Auto-Saving and Saving Revisions, I am now a happy fella!
But what about those 100′s of old records?
A simple mySQL Query will fix those !
In your wp-config.php file, Right at the bottom after the “require_once(ABSPATH . ‘wp-settings.php’);” Paste this Query, Load any page in your site ONCE and then remove the line.
37 | mysql_query("DELETE FROM `wp_posts` WHERE `post_status` = 'revision'"); |
This will Delete all those Auto-Saves and Revisions
Please post your Questions, Comments and Concerns!
Note: Back up your SQL database first! This is working good on my version of WordPress 2.6 with a few MOD's.
All consideration and Care, but no responsibility - Sheldon

Sheldon, well done man. That is going into my code snippet vault. I was hoping someone would come up with a plugin or some sort of solution to this problem. Your’s was clean and elegant and best of all, it appears to work perfectly. I only say “appears to work” because I just did it 30 seconds ago and so far so good. Just the SQL alone was worth the post. Nice work, and thank you.
Pingback: Relieve WordPress DB Bloat: Disabling Auto-Save and Revision Saving | WP Remixx
Thanks to Pepe, I have updated the mysql Query.
Thanks, very suscinct and understandable instructions.
To those arguing about deleting old mail, etc.: you guys are mediocrity and inefficiency hand in hand.
Pingback: Docs Jmini » [WordPress] Options supplĂ©mentaires dans wp-config
are you sure its
define( ‘WP_POST_REVISIONS’, 0 ); and not
define( ‘WP_POST_REVISIONS’, false ); or will both work?
also you have a calculation error, if 60=60 seconds then 600 are not 1 hour like you wrote but 10 minutes
Hi Ovidiu,
Good work on spotting that time/math error
Both Zero and False will work, where false returns a boolean of 0, where True == 1.
Hi there,
not bad…
Have a nice day
Saurooon
Great, thanks!
Hello,
Thanks for article. Everytime like to read you.
Thanks
Hobosic
I don’t normally leave comments, but I really enjoyed your post. It helpd me alot.
Hello!
Very Interesting post! Thank you for such interesting resource!
PS: Sorry for my bad english, I’v just started to learn this language
See you!
Your, Raiul Baztepo
great tips dude, how about
define(‘AUTOSAVE_INTERVAL’, 86400); //1 day
Hi! I was surfing and found your blog post… nice! I love your blog.
Cheers! Sandra. R.
i was looking for this since a week as i was trying to build posts with permalinks whose content changes daily.
i dont want to save revisions of same post daily which will occupy lots of database, though autosave is fine with me
thanks anyway
Pingback: The Life and Times of Michael Shadle » Disabling Autosave in WordPress (Properly)
Pingback: Disable Auto-Save | PAULMYATT.COM
This post was easier and did my task – http://dkgadget.com/disable-autosave-posts-pages-wordpress/
Well done bro it made my day.