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.
How to Delete and Limit WordPress Post Revisions | CoralNodes
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:
    /* @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.

    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:
    * @package WordPress
    */
    define(‘WP_POST_REVISIONS’, false);// ** 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 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 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.

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *