Post revisions is a great feature that shows the automatically saved or manually saved post revisions. You could revert any changes made in anytime if the post revisions are available. This is a great feature for many WordPress users. But, someone may find that, as a bad thing. If you have a limited amount of database storage, or you no longer need the autosave feature, this article on ‘how to disable post revisions in WordPress to reduce database size’ might help you.
What are Post Revisions in WordPress
Post Revisions are the previous-saved versions of your WordPress posts. There are automatic post revisions as well as manual post revisions. The manual post revisions are saved whenever the user clicks the “Save Draft” or “Publish” buttons inside the WordPress post editor.
The automatic revisions on the other hand will be triggered at a fixed interval if the post hasn’t been saved by the user. This can be extremely useful if the user forgets to save the post and help prevent lost work.
There is no limit for how many revisions can be saved for a post. However, if you make a lot of changes frequently, it can take up a lot of space in your WordPress database. Even if you change a single letter and save the post, WordPress will clone the entire post to another row of data. So, be sure to use it carefully, or limit it to save a smaller number of revisions.
How to Disable Post Revisions in WordPress to Reduce Database Size
To disable post revisions in WordPress to reduce database size, follow the steps given below.
- Login to your web disk (Hosting account).
- Go to the WordPress Root directory.
- Open wp-config.php located in the WordPress root directory.
- Add the following code to the file and save the changes.
define('AUTOSAVE_INTERVAL', 300 ); // seconds define('WP_POST_REVISIONS', false );
This will change the default 1-minute autosave to the 5-minute autosave. This helps you reduce the database consumption to a great extent. If you realize that you don’t need the past revisions of your WordPress posts, you can open phpMyAdmin and run the following SQL query. You can also check our article on accessing the WordPress database to know how to run the command.
DELETE FROM wp_posts WHERE post_type = "revision";
This will clear all previously saved post revisions stored in your database.
This tutorial is only for educational purpose. We do not recommend deleting the post revisions or disabling it. It is a good feature of the WordPress which help you stay updated without your content. Even if you had forgotten to save the changes, the WordPress will automatically do it for you. So, do it in your own risk.
Limit the number of post revisions in WordPress
A better way of dealing with this issue is limiting the number of post revisions saved. This will prevent your database being used up too much and also keep the functionality.
In order to limit the number of post revisions in WordPress, use the following code in your wp-config.php –
In this case, we are limiting the post revisions to 5. You can change the number to whatever number you want. Keep in mind that, once you make this change, if you have an older post with more than 5 revisions, and you make changes to it, it will delete all the previous revisions that are older than the 5 recent ones.