How to limit the number of revisions in WordPress

How to limit the number of revisions in WordPress

When too many WordPress revisions can be bad

WordPress will save an unlimited number of revisions. If you ever make a mistake you can revert to the previous post version. This might sound like a very nice feature, but by default it has no limit at all!

Every time you save an article an additional copy is stored in your database. Let’s say you have a WordPress website that has 100 posts. However because every article has at least 10 revisions stored you will actually have 100* 10= 1000 posts in your database. All post data is stored in your MySQL database, a regular post will be 100KB. Therefore the WordPress revision system will increase your database size from 10MB to 100MB!

A large database requires more resources and makes your website slower. Removing these revisions can reduce the size of your database by over 90%!

Solution: Remove or limit revisions?

Now luckily there are ways to clean old WordPress revisions. However without limits you will have to keep doing this regularly. Changing even one word will create yet another duplicate. So when you decide to modify large articles you will need to clean up again.

Wouldn’t it be better to limit the number of revisions stored by WordPress to a more reasonable number?  That can be arranged!

Step 1: Open your wp-config.php

I am going to assume that you know how to use FTP software. If not please check out our guide on how to edit wordpress files with an FTP software.

First we need to find wp-config.php. It is located in the top level directory. Usually public_html (unless your blog in installed in a subfolder like /blog/, then you will find it there). Download this file and open it.

Step 2A: Adding code to limit WordPress revisions

Now scroll down to the end of the document.  And paste the following code

/** WordPressInside Customizations */

define(‘WP_POST_REVISIONS’, 5);

This code will limit the number of revisions to 5. Personally I find this a reasonable number. However feel free to change it. I could imagine 3 would suffice for most bloggers.


Step 2B: Adding code to completely disable WordPress revisions

If you really hate revisions you can disable them completely with the following code at the end of the document

/** WordPressInside Customizations */

define(‘WP_POST_REVISIONS’, false );

But generally it makes sense to keep at least one working copy. If you end up losing parts of a large article you will regret this decision.

Step 3: Save and upload the wp-config.php

Now simply save your wp-config.php and upload it back to your server. If you followed my guide (guide will follow) then saving will automatically prompt  to upload the file.


That was it!

Now with this tiny modification you will save yourself a lot of unnecessary data in your MySQL database.

Keep in mind that revisions that were already created past the limit will not be removed. If you want to remove all or a specific number of revisions then please check out How to clean revisions in WordPress (but not all).