How to 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.

  1. Login to your cPanel.
  2. Access the cPanel File Manager Code Editor and navigate to your wp-config.php file.
  3. Enter in the following code towards the top of the wp-config.php file:
    define('WP_POST_REVISIONS', 3);
  4. 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. 

WordPress Database Showing wp_post_revisions difference

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

  1. Login to your cPanel.
  2. Access the cPanel File Manager Code Editor and navigate to your wp-config.php file.
  3. Enter in the following code towards the top of the wp-config.php file:
    define('WP_POST_REVISIONS', false);
  4. After that click on Save Changes at the top-right.

    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.

WordPress Database showing wp_post_revisions off

You should now understand how to limit or completely disable the WordPress revision functionality to help keep your hosted WordPress database optimized. If you already have a large number 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.

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

11 thoughts on “How to Limit or Disable WordPress Revisions

  1. 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.

    Add the following code snippet in wp-config.php

    define(‘AUTOSAVE_INTERVAL’, 300); // seconds

    define(‘WP_POST_REVISIONS’, false);

    See the code snippet that must be inserted above ‘ABSPATH’

    I have seen the code here if need any help you can see the full code https://www.wpblog.com/disable-limit-wordpress-post-revisions/

  2. There is strictly no difference if you have space(s) here and there as long as the values in the definition follow the declaration type and syntax convention.

  3. UPDATE: The ‘Better Delete Revision WordPress plugin’ mentioned towards the end of the article has been updated.

    Thanks for the article guys !!!

    1. Is there any different between this two code?
      define( ‘WP_POST_REVISIONS’, false );
      define(‘WP_POST_REVISIONS’, false);

      The first one has space after the bracket.

      Regards,
      Joseph

    2. Hello Joseph,

      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.

      Regards,
      Arnel C.

    3. Hi @Arn,

      Thanks for your clarification. I was told by another host to use the code with the space, so I was confused.

      Cheers!
      Joseph

    1. Hello Phred,

      To what code are you referring? Are you not having any luck with implementing one of the above solutions?

      Kindest Regards,
      Scott M

    2. 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!!

  4. When I applied the code provided above and attempted to access my site I got an error pointing directly to the line containing;

    * @package WordPress

     

    1. Hello James,

      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:

      /* @package WordPress
      */
      
      define('WP_POST_REVISIONS', false);
      
      // ** MySQL settings - You can get this info from your web host ** //
      

      I will also correct the code used above. Sorry for the confusion!

      Regards!
      Arnel C.

Was this article helpful? Join the conversation!