Easy Ways to Limit Post Revisions in WordPress – The Post revision feature in WordPress is a very useful feature and it makes it easy for users to undo changes, return posts when suddenly your internet network is disconnected, or return posts to their previous draft.
However, users should also be aware that too many revisions can increase the size of their backup file, make posting times longer, and affect the overall performance of the site as each revised post is stored in the database. It’s easy to disable post revisions, but to do that you need to edit the configuration file.
In this article, I will show you how to control and limit post revisions for post types in WordPress with a simple user interface. But if you don’t want to install a plugin, you can try the method by adding a little script. Read on the article below.
Method 1: Limit the number of WordPress revisions with code
In this first step is to limit the number of WordPress revisions you will allow. This can be a big gap-breaking step to ensure that revisions don’t accumulate again. Maybe you only want to keep 3 revisions. WordPress will save the revisions to your liking and delete the previous ones. You can also use wp-revisions-cli to clean post revisions based on the number you specify below.
Open your wp-config.php file. You need to add some code. This file is usually located in the root directory of your WordPress site and you can access it via FTP.
Urgent! Editing the source code of a WordPress theme can break your site if not done properly. If you feel uncomfortable doing this.
The code below has to be entered above ‘ABSPATH’ otherwise it won’t work. Again, you can change the number for how many revisions you want to keep in your database per page or post.
It should look something like this.
And below is the code if you want to disable post revision. So with the code below, no post revisions will be stored in your database. However, I prefer that you choose the code above because it still keeps revisions and you can use it as a backup when you want to return the post to the previous draft.
Method 2: limit the number of revisions to WordPress with plugins
The first thing you need to do is install and activate the plugin WP Revisions Control. After activation, just visit Settings »Write to control revisions.
Scroll down a bit on the settings page, and you’ll see the New WP Revision Control section. You can specify the number of revisions you want to keep for each post type.
If you don’t use a custom post type, then you will only see Posts and Pages, the rest of the plugin will show all your post types.
If you want to save all revisions for the post type then simply leave it blank and WordPress will save all revisions for the post type.
Once you are done, just click on the button Save Changes to save your settings.
The following tutorial on controlling or limiting the number of revisions in WordPress, hopefully this article helps you control revisions for post types in WordPress so that your WordPress site becomes faster and saves your database capacity.