DWR.IO

WordPress Post Revisions

Published on 06/26/2012

As of version 2.6, WordPress introduced a feature which autosaves your posts as revisions while you are editing them in the dashboard. While this functionality can be very useful, it can also be a bit of an annoyance. If a single post ends up going through multiple edits or simply takes a while to get finished, those revisions can add up. I personally don’t see the need to have billions upon billions (ok, slight exaggeration) of revisions saved for every one of my posts. Additionally, that is just extra information that is getting stored in your database, which you may not need. Disabling this feature or limiting the amount of allowed revisions (which is what I opted for) is actually quite simple. It only takes one line of code in your wp-config.php file.

/** Disables WordPress automatic post revisions. **/
define('WP_POST_REVISIONS', false);

/** Limits revisions to specified number (second parameter). **/
define('WP_POST_REVISIONS', 5);

Additionally, posts are autosaved every 60 seconds by default. This can be easily adjusted as well.

/** Adjusts autosave interval to 120 seconds. **/
define('AUTOSAVE_INTERVAL', 120 );

There are just a few important things to note:

require_once(ABSPATH . 'wp-settings.php');

It took me a little while to figure that last one out, as I had my adjustments placed at the very end of the file and wondered why it was not seeming to work.

And that’s that. Nothing too daunting. Hopefully in the future, WordPress will have the ability to manage this directly through the admin. Until then, it’s just a line or two of code to add to your wp-config.php.

References / Resources

---

Category: General

Tags: post revisions

← Back to all notes