Disable WordPress Drafts & Revisions

By .     1 Comment

Today’s computer tech tip involves disabling two features in WordPress: Automatic Drafts & Revisions. They’re intended to be helpful, but they’re not for everyone. I would prefer to see these as options to enable/disable within the Admin Dashboard, but hard-coding the changes will suffice for now. I may have mentioned it before, but I prefer coding my articles in HTML with Notepad++ and later copy/pasting them in, so drafts and revisions aren’t necessary to me.

Disable Automatic Drafts

While writing a post in WordPress, the system will automatically assign that post an ID number, adjust the basic permalink with this ID, and save the post as a draft. It sounds like a helpful tool, right? You won’t lose a post in the event your browser crashes or you encounter another problem. As I said though, this feature isn’t for everyone.

For a few moments, this automatic action freezes the post screen. I found that it’s more likely to happen once I give the post a title. Sometimes, if I’m quick enough, I can type the title and quickly hit “Publish” before a draft is saved, saving me from waiting for the “Publish” button to become available again.

If I actually intend to save a Draft and come back to it later, the published version sometimes gets a different post ID. Then, I have a draft version and a published version of the same post. You’ll also notice I use the pretty permalink structure /%post_id%/%postname%/ and sometimes the post IDs jump a bit. I’d prefer if they go in chronological order and don’t skip. I could continually adjust the MySQL database via phpMyAdmin, but there’s a better way.

In order to disable automatic drafts, you just have to comment out one line. Open up /wp-admin/post-new.php and locate wp_enqueue_script('autosave'); on line 36. Simply add two slashes before that line to make it a PHP comment line and you’re done.
// wp_enqueue_script('autosave');

After making this adjustment, your posts won’t automatically be saved as drafts. You will still be able to manually save a post as such, so don’t worry about that. If you have duplicate drafts already, it’s easiest just to delete them from the Admin Dashboard rather than adjust the database yourself.

Disable Revisions

Post revisions is an annoying feature to me. Every little change I make to a post – even if I immediately “Update” the post afterward – is first saved as a revision. Sometimes, I go to the edit screen just to take a look and a revision is saved without any change being made. (This brings me to a minor addition I’d like to see: a “Cancel” button in the post edit screen.)

Another weird occurrence of revisions is when I go to edit a post, completely ignoring the revisions (as I always do), “Update” the post, and then get notified there is a more recent revision. Sorry WordPress, but the adjustment I just made is the most recent in both time that I made it and personal satisfaction of the post content.

I easily rack up 10+ revisions for each post. The more entries to the database, the larger it is. In turn, the longer it takes the server to generate a backup, the longer it takes to download, and the more space it takes up on my hard drive. So, if you’re organized enough to keep a folder of HTML or Word documents for your posts, you likely won’t benefit from post revisions at all.

Fortunately, disabling post revisions is also very simple. Open up the wp-config.php file, which is located in your website’s root public directory. At the very bottom, add the following lines:
// disable post-revision nonsense
define('WP_POST_REVISIONS', FALSE); // false or # of revisions to keep

As the comment says, you can adjust the False boolean to a number, so each post will keep only the most recent X number of revisions.

Purge Old Revisions

If you decided to disable revisions completely, you likely want to delete all existing revisions as well, which means getting your hands dirty in the database. Login to your web host’s control panel, locate the database manipulation tool (phpMyAdmin is the popular choice), and open up the database for your WordPress installation. Over on the SQL tab, enter in the following query:
SELECT * FROM wp_posts WHERE post_type = 'revision'

The code reads: Select all rows from the wp_posts table where the post_type is a revision. In order to quickly delete all these rows of revisions, enter in the following query:
DELETE FROM wp_posts WHERE post_type = 'revision'

What features about WordPress annoy you? What modifications have you made to the wp-config.php file or other core files?

Posted in: Web Development



is the site owner of Computer Tech Tips and is passionate about computer technology, particularly Windows-based software, malware removal, and web development. He enjoys helping people troubleshoot computer problems and providing technical support to family, friends, and people around the net. Xps wrote 79 article(s) for Computer Tech Tips.


 Subscribe to comments: this article | all articles

Comments (1)

  1. Smith says:

    You can even edit the wp-config.php file and add a simple line of code which will disable the auto draft being saved.

    One method I found is over here http://www.l337fx.com/disable-draftrevisions-wordpress.html

    But they state revisions too, and I dont think disabling revisions are worth unless you have large post counts being made.

    Admin edit: April 2013, the link in this comment is no longer valid, so it’s been removed.

Comments are automatically closed to prevent SPAM.