Occasionally updating or revising a post on your WordPress site isn’t a time-consuming task. It also doesn’t take up a lot of space. However, over time, revisions do start to add up and can eventually take up a considerable amount of space on your database.
Whether you’re in a pursuit to free up some much-needed space or prevent the matter altogether, disabling or removing old post revisions from your WordPress site is an available option. Doing either can help reduce database bloat and optimize performance.
In this post, we’ll discuss what post revisions are and how they can be used. We’ll explain why you’d want to disable, limit, or remove them, and walk you how to do each one. Let’s get started!
Post revisions, which are sometimes referred to as revisions, are a built-in feature of WordPress. They are useful because they make it easy to revert to a previous version of a post and undo the changes you made.
For example, let’s say you decided to delete some paragraphs in your post. However, later, you realize that edit was a mistake and want to recover the information you eliminated. With post revisions, you can easily do that.
In WordPress Gutenberg, this feature is located on the right navigation panel under Document > Revisions:
If you’re still using the Classic Editor, you can find the revisions under the Publish box, also in the right navigation panel:
When you’re viewing revisions, WordPress shows you the new information that was added as well as what was removed through respective highlighting. New changes will be highlighted in green:
There’s also a mode to compare versions of the revisions. When you select the version you want, you can click on the Restore This Version button.
With the WordPress revisions system, each update or draft is recorded and gets stored in your WordPress database. While having the option to view the changes made to a post and restore previous versions can be super helpful, it can also take up space.
The more revisions you make, the more bloated your database can get. Database optimization is an important part of WordPress site maintenance. Therefore, managing the revisions on your site is highly recommended. Removing old revisions, for example, can reduce the size of your backups.
There are three main options to choose from for managing post revisions. You can disable them completely, limit how many are allowed, and remove the old post revisions. Below, we’ll cover how to go about each of these, starting with disabling post revisions.
One way to prevent an accumulation of revisions from piling up in your WordPress database is to remove the opportunity for them to in the first place. You can do this by disabling post revisions.
In order to disable post revisions permanently, locate your WordPress site’s wp-config.php file that’s located in the root directory. Add the following line of code at the very top:
define( ‘WP_POST_REVISIONS’, false );
This line of code disables post revisions from being saved to your database in the future. If you’d like to enable this option sometime in the future (for whatever reason), simply replace the line with:
define( ‘WP_POST_REVISIONS’, true );
When you’re done, be sure to save your changes before exiting. Completely disabling post revisions isn’t necessarily something we recommend. There are other less drastic options you can pursue to optimize and manage revisions in your database. However, if you do want to do it, it helps to know that option is there and can easily be activated or deactivated when necessary.
If you’re like most people, you’ll want to save a couple of post revisions for every post you add to your site – just to be on the safe side. For this, the best option is to set a limit on the number of post revisions that are saved to your database.
You can do that by adding the following line to your wp-config.php file:
define( ‘WP_POST_REVISIONS’, 3 );
This line saves the three most recent post revisions instead of all of them, meaning the older ones are automatically deleted once newer versions are saved. You can replace the number three with another integer depending on your preference.
Instead of limiting the post revisions to a pre-defined number, you can also increase the auto-save interval to save fewer revisions. To do this, open up your site’s wp-config.php file and add the following line at the top:
define( ‘AUTOSAVE_INTERVAL’, 600 );
By default, WordPress auto-saves your post revisions every minute (60 seconds). However, by adding this line it will save them every 10 minutes (600 seconds). This automatically reduces the number of post revisions that are stored in the database.
If you shy away from coding or adding code to your site’s wp-config.php file, you can always get the job done by installing a plugin, such as WP Revisions Control. After you install and activate this plugin, you can configure that number of post revisions allowed by going to Settings > Writing:
It’s important that you understand that the techniques we covered so far disable or limit post revisions from being saved for future posts. What about the past revisions?
In this section, we’ll cover the two methods you can use to permanently remove old post revisions from your WordPress site’s database. If you’re familiar (and comfortable) with SQL queries, you can go with the first method. However, if you’d prefer using a plugin then go ahead and skip right down to the second method.
Deleting post revisions from your database is one of those things that you should be able to do without having to install a plugin (although there are plugins for it too, which we’ll cover next). After all, you’re trying to save space and installing a plugin generally goes against that.
In order to delete all of your past post revisions from your site’s database, login to the cPanel of WordPress site’s hosting account and click on the phpMyAdmin icon.
In the left navigation panel, find and click on your WordPress database. Click on the SQL tab:
You’ll be brought to the phpMyAdmin SQL interface. Next, where you can run an SQL query. You can do this by entering the following snippet of code:
DELETE FROM wp_posts WHERE post_type = "revision";
Make sure to replace wp_ with your own WordPress database prefix. Then click on the Go button. This will initiate the command:
This SQL query removes all posts from your database that have post_type = “revision”. You might want to create a backup of your database prior to running this query as an added security measure. In our opinion, it’s always best to make backups of your database before you make drastic changes to it.
Although deleting post revisions from your WordPress site can be accomplished by running a single SQL query, you might find it easier to install a plugin and let it do all the work. This might be because the plugin has added benefits (database maintenance, removes excess files etc.) or simply because you’re not comfortable with programming.
Whatever the reason, there are a variety of plugins you can use to delete old post revisions. One you might consider using is WP-Optimize:
Although this plugin offers a premium version with advanced features, you can download it and use it to delete old revisions for free. WP-Optimize is an all-in-one plugin that you can use to optimize your WordPress database. In addition to using it to delete revisions, you can also use it for important maintenance tasks such as image compressing and caching.
Once you install and activate the plugin, it will add a WP-Optimize menu item to your WordPress dashboard. To delete post revisions, you can navigate to WP-Optimize > Database.
Under Optimizations, you can check the box next to ‘Clean all post revisions’, then click on the Run Optimization button:
You can delete the plugin or deactivate it once you’re finished with this process. That way, you don’t have to worry about it taking up any unnecessary space in your WordPress database.
Post revisions don’t slow your site down or threaten the User Experience (UX). They do, however, start to take up a lot of space on your site’s database over time. Fortunately, limiting or removing old post revisions will clear up a significant amount of space on your database.
As we discussed in this post, there are two methods you can use to disable, limit, or remove old post revisions from your WordPress site:
Which method are you most comfortable with for disabling/removing old post revisions? Is there another method you use? Let us know in the comments section below!
Trying to figure out how to start an online course so that you can share…
Considering using LearnDash to create online course content with WordPress? LearnDash is a popular WordPress…
WordPress XML files see a lot of use for me as a content creator, and…
If you’re looking for a way to deliver an online course, complete with all the…
Search Engine Optimization (SEO) is crucial for any website that wants to maximize its traffic…
Kinsta is a notable brand in the WordPress hosting space. The standout aspect of the…
View Comments
I think post revisions are worth having and the feature has saved me more than once. However, I think a plugin to bulk remove all revisions, manually, would be more beneficial than coding them out of Wordpress altogether.
Hi Ash,
If you want to use plugin to remove post revisions, check out this post -
https://www.wpkube.com/plugin-for-wordpress-post-revisions/
Thanks for commenting.
Great plugin...
I am using GD Press Tool :)
http://img214.imageshack.us/img214/1632/gdpresstool.png
Hi Devesh,
I would agree with Ash. They can be useful but also a pain in the behind. A plugin would be a good option, maybe that's something you could look into.
Pete
Hi Pete,
Glad you found it useful. If you want to use plugin then check out this post
https://www.wpkube.com/plugin-for-wordpress-post-revisions/
Are there any considerations why we need to remove it?
If you aren't utilizing this feature then there is no need of keeping it.
You can reduce your blog database size by removing and disabling the post revisions from wordpress.
@Dana if you have multiple authors in your site I solely recommend to keep revisions enable, the reason is you're able to back the old post at anytime, revisions seems to be the history of all your created and updated post and pages, you can also visit Disable and Remove All Post Revisions for more information.
Hope it helps.
Very cool. Thanks for the plugin URL.
You're Welcome Ash. If you need any help about WordPress then don't hesitate to contact us.
This would help the bloggers get rid of another plugin.
It is better to have a functionality with few lines of code rather than having a plugin.
I am going to remove that plugin from my blog. Thanks for sharing this.. :)
Yeah, doing manually is much better then using plugins.
Thanks for the nice comment Amandeep.
Im in Myphpadmin but what database do you run the query for. I keep getting error.
DELETE from wp_posts WHERE post_type = “revision”;
Hey Luke,
If you have multiple sites on your server, you need to find out the database name (you can see the name in wp-config.php file).
Hope that helps, if you need any help, let me know.
Hi,
I added
define( ‘WP_POST_REVISIONS’, false );
in my website's root directory wp-config.php file but it didn't work (revisions are still being saved) and errors are registered in the error_log:
[09-Apr-2020 08:58:31 UTC] PHP Warning: Use of undefined constant ‘WP_POST_REVISIONS’ - assumed '‘WP_POST_REVISIONS’' (this will throw an Error in a future version of PHP) in /home/wk32vkj3/mywebsite.com/wp-config.php on line 22
Maybe something has changed since you wrote this post?
Try removing the single quotes around WP_POST_REVISIONS and add them manually, the encoding on the post content changed them to other versions of a single quote which don't work inside of code.
Hello, I have been using this trick for ages, but it does not seem to work anymore. I just deleted 83 revisions from the database of my new site that im working on.
I double checked, I have in wp-config.php
define('WP_POST_REVISIONS', false);
Whats going on. I have the new block editor disabled, could that be related?
Brilliant, thank you, just what I was looking for!
We are in the process of removing 30,000 revisions which have basically disabled our bloated data base. So limiting the number that is created is a really good idea. We now just keep the one auto save revision.