Limit or disable WordPress revisions

In this article I’m going to talk about WordPress revisions and why you might possibly want to limit or disable the revision history of your WordPress pages and posts.

WordPress provides revision control on any pages or posts that you create which allow you to go back and see previous edits that you’ve written over in the database. While this can seem like a great thing to have, over time it can lead to a lot of unessary overhead in your WordPress database.

For instance let’s say that you’ve previewed a post that you’ve been working on 7 or so times, each of those revisions you might have just changed around a word or two, or made some very minimal changes. However in the WordPress database you would now have 8 copies of your original post, the 1 main one and 7 revisions storing the full content of that past revision and not just the changes made since the last one.

Limit WordPress revisions

Using the steps below I’ll show you how you can limit the number of revisions that WordPress will store per page or post. By default there is no limit on the amount of revisions so any limit you impose is going to help keep your WordPress database more efficient. We’ll be using the WP_POST_REVISIONS setting in our wp-config.php file to accomplish this.

In this example we’re going to set our max amount of revisions per page or post to 3. So in total there will be 4 entries in the database per page or post, 1 for the original itself, and then the 3 latest revisions. In this case I simply started a new post with the title Test and then in the content of the post I simply entered in Test #1 and then previewed the page, then I entered Test #2 and previewed the page again up until I got to Test #7.

Enter in the following code towards the top of the wp-config.php file:
/* @package WordPress*/
define('WP_POST_REVISIONS', 3);// ** MySQL settings - You can get this info from your web host ** //

After that click on Save Changes at the top-right.

Below is a screen shot of the WordPress database showing the difference between the default WP_POST_REVISIONS settings, and the ones we just set.

Disable WordPress revisions

In the steps below I’ll show you how to completly turn off WordPress revisions for your pages and posts. Again we’ll be using the WP_POST_REVISIONS setting in your wp-config.php file to make these changes.

Also again I’ve done the same thing where I created a new post called Test, and then I put Test #1 as the content and previewed the page, then I changed the content to Test #2 and previewed it again. I repeated these steps till I got up to Test #7

Below is a screen shot of the WordPress database that no revisions are being stored, and only 1 row is being used for my post.

You should now understand how to limit or completly disable the WordPress revision functionality to help keep your WordPress database optimized. If you already have a large amount of pages and posts that have a lot of revisions we would recommend possibly trying out the Better Delete Revision WordPress plugin, while this plugin is old it still functions perfectly fine from the testing that we’ve done.

Thoughts on “Limit or disable WordPress revisions”

As we all know that post revision is a best WordPress feature but as it’s not for all users that have limited database space or for those users who do not need the auto save feature for their website and for those users disabling the Post Revision feature is perfect option.

I would use the second version, without the space after “false”. Many commands will not work properly because of a simple space in the wrong place. This happens a lot in HTML. I hope this helps to answer your question, please let us know if you require any further assistance.

Thank you! Worked like a charm! I had accidentally(?) published a complex WordPress post and had to “Private” it to proceed with, would you believe, over 200 tweaking revisions over several days!! Yikes! I used your method above, changing revision number to 7 (to be safe), and just added another teak after publishing, and I’m now on 7 revisions only! I’m switching hosting to you guys very soon, just cleaning up my email account first. Cheers!!

Thanks for the question. The problem has to do with a missing slash in the code above. The first part is supposed to be a comment. It’s missing a slash. So when you copied it, the comment doesn’t work correctly. You can either remove the section with the asterisks, or add the ‘/’ that supposed to be in front of the “*”. The code should look like this:

InMotion Hosting is a leading web hosting company serving customers around the world. We provide reliable, high-performance hosting environments that are affordable and easy to use, but the hallmark of InMotion is excellence in customer service. Our aim is to delight every customer with friendly service that is readily available, expert and effective.
InMotion is a trusted partner for businesses both large and small, with over 10 years in the hosting business and over 100,000 satisfied customers hosting their websites on our servers. We care about our community and the environment, with green data centers and ongoing sustainability programs.

LIMITED TIME ONLY! Get all the amazing speed and performance of our WordPress Hosting Platform, including free SSL and much more. That means you get 2 websites, 80GB of storage, unlimited email accounts and a FREE JetPack Personal License, all for $6.99! https://zcu.io/eCNw