If you are like me then you are a stickler for speed. There is nothing worse than a slow website! One of the ways in which I keep my WordPress websites running fast is to disable post revisions. I never use them and some WordPress hosting companies even disable this feature to keep your database smaller and your site running fast.
Follow the directions below on how to disable WordPress post revisions (and page revisions). There is also an alternate option to limit post revisions.
Note: Revisions aren’t enabled by default on other types of posts, such as WooCommerce products or custom post types. So you don’t need to worry about them. Just the default WordPress posts and pages.
- Option 1: Disable WordPress post revisions with code
- Option 2: Disable WordPress post revisions with a plugin
Option 1: Disable WordPress post revisions with code
First we will need to open up your wp-config.php file. This should be located in the root of your WordPress site. Please back the file up first.
We are then going to insert the following code. You will notice I am also adding a line to change the default autosave interval from 60 seconds (1 minute) to 300 seconds (5 minutes). Note, when you disable the post revisions there is still one autosave per post.
//disable WP Post Revisions define('AUTOSAVE_INTERVAL', 300); // seconds define('WP_POST_REVISIONS', false);
This needs to be inserted above the ‘ABSPATH’ otherwise it won’t work.
See my example below.
Save your wp-config.php file and re-upload it to your server. And your done! The revisions option next to your Publish button will no longer show.
Maybe you have a client that wants revisions but you want to limit them. You can set a number of revisions. WordPress will keep that number and delete any previous ones. See the alternate code below.
define('AUTOSAVE_INTERVAL', 300); // seconds define('WP_POST_REVISIONS', 3);
The above code will save only three revisions. If you don’t set a limit you might end up with a lot of revisions over time. See this picture below from a client’s site I was working on. They had 239 revisions on just one page. The client has about 600 pages. If you do the math that could be an additional 143,400 entries in your database.
Option 2: Disable WordPress post revisions with a plugin
Your second option is to use a WordPress plugin to disable and or limit WordPress revisions. We developed the Perfmatters plugin, a lightweight WordPress performance plugin.
In the plugin, you can either disable post revisions or limit them with one click. This can be a lot easier than worrying about code.
And make sure to check out how to disable scripts on a per-page/post basis in WordPress with Perfmatters.
Hopefully, now your WordPress revisions won’t be bloating your database. And don’t forget to also delete the old ones. Check out my other post on how to delete old WordPress revisions and optimize your database.
As always feel free to comment below!