Thinking of limiting post revisions in WordPress? You are in the right place. I agree that a slower website can turn off the viewer and force them to close the site. Even if you have awesome content on your website,
So, you should optimize your WordPress database regularly to speed up your website, which would be a big relief and provide a better user experience.
And I agree that it’s not possible to take care of the website all the time. So here, you can always take the help of some tools.
At the same time, WordPress CMS is designed in such a manner, that it creates revisions to rescue the content. So that in case anything goes wrong, you can always revert.
But, dramatically it increases the WordPress database size, as it creates a copy after some intervals and is stored in the WP database.
Nothing to panic about, adding some code to the core files, will do the maintenance part.
To make the website lighter you need to clean up the WordPress database regularly with the WP-Sweep plugin.
Because all the revisions used to get stored in the WordPress database.
So here we are going to see how we could limit the Revisions to get created in the WP post.
How To Limit Post Revisions in WordPress
This process is quite simple and can be done just by adding a simple code in the WP-Config file.
- Step 1. Open your Hosting CPanel and log in to it.
- Step 2. Now you need a
wp config.php
file, which can be accessed from the Hosting Control Panel – File Manager, there you would be able to find it.
- Step 3. Look for “
wp-config.php
“, then right-click on it and select “Code Edit
“. to add some code to the file.
Note: It’s always good to take a backup of the file just being on the safe side, right-click on the wp-config
file, and download it.
It will open up the editor and we are about to add some code to limit the revisions.
In this section find a code that looks something like this,
define(‘WP_DEBUG’, false);
/* That’s all, stop editing! Happy blogging. */
Step 4. Now paste the below code, above it.
/* Sets limit on WordPress revisions */
define(‘WP_POST_REVISIONS’, 2);
Here, the number “2” is mentioned because we would like to create 2 revisions only. You can change, the number of revisions you would like to store in.
It’s highly recommended to keep it minimal to keep the WordPress database to be lightweight. After all, that is the exact purpose of doing it. Or else, you will end up storing a lot of revisions for your entire site.
Make sure you are putting the code in the right place in wp-config
. It won’t work if do it below ( !defined(‘ABSPATH‘) ),
Check out an example of the earlier published post, and see the number of revisions it created.
Just assume if one post creates so many, then what the post revisions would be for your entire site? It was just an example, it creates more every time you make an update to your posts.
Once done, save the WP-config.php file and you are done. You have successfully restricted the revisions.
Now you will be able to see the changes while editing any of your posts, check out the image as an example. Due to we have made some revision control to “2”. So, it’s not creating more than that.
And just in case, if you want WordPress not to create any revisions at all. Disabling it is also possible easily.
Disable the WordPress Post Revisions
The process is the same for even this, just replace the number “2” with “false,” That means it will look something like this.
/* Sets limit on WordPress revisions */
define(‘WP_POST_REVISIONS’, false);
You can test this, whether it is working or not. Again open any of your posts, you won’t be able to see the revision options at all.
Doing the WordPress cleanup, can keep the database tidy and speed up your WordPress site. The above procedure is quite handy for those who don’t want to install too many plugins.
Though a few plugins also do the job, WP-Sweep is the recommended one to clear the revisions and clean the WP database.
Do share the article if it helped you by reducing your WordPress database size. I would like to hear, the comment section is open for you.