September 19, 2016 - No Comments!

How to limit WordPress revisions to save your database

First of all: What is WordPress revisions? WordPress saves revisions and stores a record into database for each saved draft. This could be useful to roll back to any previous post or page version; quite interesting uh? This revisions of this system, however, threatens to massively increase your database sizes, thus slowing your website.

As described WordPress revisions can be useful, but it would be interesting to be able to limit them to a maximum number, saving your database health.

In this article we will see how to restrict the maximum number of revisions in a simple way and especially without using plugins.


Few months ago, we are developing a WordPress site for a client who would use it mainly for the blog function. The main problem was to avoid the database would become unmanageable due to the high number of posts and reviews while the months passed.

We couldn't totally disable the revisions because the customer would have used them, but it was necessary to find a way to to contain them.

Ok, let's start and fix this problem!

First we will need to open up your wp-config.php file, usually it will be located in your root folder, and place these lines of code above the 'ABSPATH':

define('AUTOSAVE_INTERVAL', 300);
define('WP_POST_REVISIONS', 3);

As you can see we change the default autosave interval from 1 minute (60 seconds) to 5 minutes (300 seconds) and then limit to 3 the maximum revision number of revisions for each post / page. These exemptions would significantly decrease the impact that the revisions could have on the database, but keeping the function active.

Now it remains only one last step to complete, that is share this article if you found it useful 🙂

Related Post

Published by: Themelovin in Code

Leave a Reply