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
Related posts:


16 Responses to “Disabling WordPress Auto-Save and Revision Saving”
WPRemixx Admin 11/08/2008 01:47am
Sheldon 28/08/2008 09:00am
mysql_query("DELETE FROM `wp_posts` WHERE `post_status` = 'revision'");Robert 01/09/2008 06:05pm
To those arguing about deleting old mail, etc.: you guys are mediocrity and inefficiency hand in hand.
Ovidiu 22/01/2009 09:32pm
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 :-)
Sheldon 27/01/2009 08:45pm
Good work on spotting that time/math error ;)
Both Zero and False will work, where false returns a boolean of 0, where True == 1.
Saurooon 05/02/2009 01:45am
not bad...
Have a nice day
Saurooon
Kevin Kelly 20/03/2009 02:48pm
Hobosic 23/03/2009 12:41am
Thanks for article. Everytime like to read you.
Thanks
Hobosic
Buy Acai Berry 28/03/2009 02:27am
RaiulBaztepo 30/03/2009 08:55pm
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
walnutz 05/06/2009 08:14pm
define('AUTOSAVE_INTERVAL', 86400); //1 day
sandrar 11/09/2009 02:34am
bruhaspati 13/10/2009 02:12am
i dont want to save revisions of same post daily which will occupy lots of database, though autosave is fine with me
thanks anyway