How to Limit Number of WordPress Revisions
In one of my previous posts, I wrote how to disable WordPress Revisions. In that article, I also wrote about the importance of revisions. Revisions help a lot in recovering the post content if you did some wrong changes and saved. So, I don’t recommend you to disable WordPress Revisions. If you are worried about the storage and performance of your blog, you can limit the WordPress revision.
Yes, WordPress also allows you to set the number of maximum revisions you want in your WordPress blog. In this way, you will not be disabling the revisions but limiting it to keep storage optimized. In this article, I will write steps to limit the number of WordPress revisions.
Also read: Optimize database of WordPress blog
Limit Number of WordPress Revisions
Like other tasks, you can either limit WordPress revisions using code if you know how to edit files or just install a plugin to do it easier. In this article, I will tell you both ways. If you do not want to install any plugin, you can use the second method where you will have to add a code in a WordPress file.
How to Limit Number of WordPress Revisions Using WordPress Plugin
If you want the easier way, you can just install a plugin that will do this job for you.
There is a plugin called WP Revisions Control. It lets you limit WordPress revisions. After you have installed and enabled this plugin, it adds a setting page where you can set the number of revisions you want to set. Go to Settings > Writing to specify the number of revisions for each post type.
After saving this setting, it will keep the number of revisions of a post as per the value to added.
How to Limit Number of WordPress Revisions Using Code
It requires access to WordPress files. You can either use cPanel’s file manager, FTP or any other panel if you have installed on your hosting to manage your hosting and files.
Step 1: Access the root of your WordPress site directory. You can do it using the file manager of hosting software or FTP.
Step 2: Open the wp-config.php file in edit mode. I recommend you to first download this file to avoid any issue if you made wrong changes.
Step 3: Add the code given below and save the file. Add it above the ‘ABSPATH’ otherwise, it won’t work. The below code is for 3 revisions. You can change this number as per your interest.
This code will only save three revisions. If you don’t set this limit, WordPress will keep saving a lot of revisions over time.
WordPress keeps autosaving your article in the form of revision. If you want, you can also change the autosave interval. Just add the following code in the same file.
define('AUTOSAVE_INTERVAL', 300); // seconds
In case your WordPress website stops opening and you see a white page of the PHP error page, you may have done something wrong. You can reupload the original file you downloaded before editing.
Also read: How to Disable WordPress Post Revisions
WordPress revisions help a lot but having too many revisions makes database large and ultimately affects the load time. If you have thousands of posts, you will see a considerable effect of a large number of revisions. So, limiting the number of WordPress revisions will surely help you a lot.