
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 theWP_POST_REVISIONSsetting in ourwp-config.phpfile 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 titleTestand then in the content of the post I simply entered inTest #1and then previewed the page, then I enteredTest #2and previewed the page again up until I got toTest #7.
- Login to your cPanel.
- Access the cPanel File Manager Code Editor and navigate to yourwp-config.phpfile.
- Enter in the following code towards the top of thewp-config.phpfile:
/* @package WordPress
*/define(‘WP_POST_REVISIONS’, 3);
// ** MySQL settings - You can get this info from your web host ** //
After that click onSave Changesat the top-right.Below is a screen shot of the WordPress database showing the difference between the defaultWP_POST_REVISIONSsettings, 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 theWP_POST_REVISIONSsetting in yourwp-config.phpfile to make these changes.
Also again I’ve done the same thing where I created a new post calledTest, and then I putTest #1as the content and previewed the page, then I changed the content toTest #2and previewed it again. I repeated these steps till I got up toTest #7
- Login to your cPanel.
- Access the cPanel File Manager Code Editor and navigate to yourwp-config.phpfile.
- Enter in the following code towards the top of thewp-config.phpfile:
* @package WordPress
*/define(‘WP_POST_REVISIONS’, false);
// ** MySQL settings - You can get this info from your web host ** //
After that click onSave Changesat 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.
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.