Would you believe that WordPress saves a copy of your post every time you hit the Save Draft button on the editor’s sidebar? This is no small thing since it means not just saving content but preserving it on the server.
WordPress post revisions can fill your WordPress site’s database with useless content if left unchecked.
The post will explain why you should not let your site store continuous revisions of posts dating up to when you published them.
In the following sections, we will implement some solutions that will enable us to limit, disable, or clean up WordPress post revisions.
- Why Is It Important to Limit or Disable WordPress Post Revisions?
- The Solutions Are Here
- Two Methods to Disable or Limit WordPress Post Revisions
- By Using a WordPress Plugin
- By Using the wp-config.php
- How to Clean up WordPress Post Revisions
- Clean up WordPress Post Revisions Using LiteSpeed Cache Plugin
- Take Advantage of Your WordPress Post Revisions Today
Why Is It Important to Limit or Disable WordPress Post Revisions?
I’ll start with a quick introduction.
WordPress saves each draft as a revision whenever you save it.
That way, if you mess up something in your post, you can very quickly go back and restore a previous version if necessary. The truth is, this is generally a good thing, which is why it is a feature built into the WordPress software.
In the WordPress editor, you can see how many revisions a piece of content has gotten by looking at this column.
When you click this link, you will see an interface that will allow you to review and edit the revision. If needed, you can also restore a previous revision.
This feature is excellent, but there’s still this one problem.
Your WordPress site’s database keeps track of your revisions on each page, so each revision is a new entry there. Those revisions are cumulative and can add a lot of unnecessary bloat to your database over time.
It is improbable that you would ever need access to old posts that contain revisions, especially if they are older.
Additionally, assume you are storing unlimited revisions for each blog post (the default behavior). If that is the case, you may end up with tens or hundreds of revisions for a single piece of content.
You can always refer to all the revisions until you need them, but chances are you’ll rarely need to look at more than five revisions at a time.
The Solutions Are Here
We can resolve this problem in a couple of ways.
- You can set the maximum number of revisions that WordPress will store for a single piece of content at something like 5. WordPress will still store revisions for you, but it won’t save hundreds of revisions for a single post.
- The revisions feature is entirely disabled. Revisions are a handy feature, so this seems like overkill. I’d instead limit them. Let’s say you turn them off altogether. Therefore, you must be cautious when working with WordPress’s editor because you can no longer restore things if something goes wrong.
- You use database cleaner plugins periodically to remove obsolete revisions. It is possible to do this manually, or many plugins have a scheduler for automatic cleaning.
The following sections will walk you through implementing all three solutions.
Two Methods to Disable or Limit WordPress Post Revisions
You have two main options for limiting or disabling WordPress post revisions:
- Through the use of a plugin
- Using the wp-config.php file in your site
I will show you both approaches.
By Using a WordPress Plugin
If editing your website’s code is not your cup of tea, I recommend using this plugin method. It is the most straightforward way to limit post revisions.
What if you want to disable post revisions entirely instead of just limiting the number? If that’s the case, I recommend Joel James’ free Disable Post Revision plugin. Joel is a well-established developer, and it’s easy to use.
Install and activate the plugin. You will be able to disable revisions on certain post types in the Settings -> Writing section. You’re done!
However, suppose you prefer to limit the number of post revisions but not fully disable them. In that case, that is possible by using the free WP Revision Control plugin.
With this plugin, you can restrict individual post types.
Once the plugin is installed and activated, go to the Settings -> Writing page. You will find the WP Revision Control section here.
There you can set the maximum number of revisions for each different post type.
Whenever in doubt, storing around 3 – 5 revisions is a good number to start.
By Using the wp-config.php
The wp-config file of your site is easy to work with if you consider it to be user-friendly. By adding a single line of code to the file, you can also disable and limit your post revisions.
You can edit your WordPress site’s wp-config.php file by using SFTP or DirectAdmin’s File Manager.
Then, add one of the following lines of code to the wp-config.php file.
To turn off WordPress post revisions.
To limit WordPress post revisions.
You may change the 4 to any number. These numbers indicate how many revisions to keep in your database.
In this example, it will save the last four revisions before overwriting older revisions.
How to Clean up WordPress Post Revisions
Cleaning up revisions with a database cleaner plugin is another strategy to optimize your WordPress site’s handling of post revisions.
Here are a handful of plugins you could use to accomplish this task:
It is up to you to choose which one to utilize.
When it comes to revisions, I like Optimize Database after Deleting Revisions because it gives you the option to delete the entire revisions or keep a certain number of revisions.
There is no impact on your site’s existing caching plugins since the plugin only does database cleaning.
You can easily use the plugin. After installing and activating the plugin, you will need to configure it in the Settings -> Optimise Database.
The following options are available:
- Delete revisions for particular post types.
- Delete only revisions older than X number of days, such as revisions more aged than 30 days.
- A maximum number of revisions you can make for any one piece of content.
If you wish, you can also remove some other unwanted data from the database.
Then, go to Tools -> Optimize Database to clear out your post revisions.
Always make sure your database is backed up before conducting any operation.
After creating a safe backup of your site’s database, you can click the Analyze button to take a test run.
This lets you know how many revisions your site has but does not delete anything.
Those revisions can then be deleted according to your settings by clicking the Optimize button.
The plugin will then show a summary of everything it did.
Clean up WordPress Post Revisions Using LiteSpeed Cache Plugin
If you have installed the LiteSpeed Cache plugin, you can clean the revisions easily.
Click on the LiteSpeed Cache -> Database, and it will open the Database Optimization page.
Then click on the Post Revisions, and the plugin will clean the revisions from your database.
Take Advantage of Your WordPress Post Revisions Today
Post revisions are a helpful feature in WordPress, so you can save your work and revert when needed.
WordPress post revisions can lead to your website’s database being clogged with tens or hundreds of unnecessary revisions when left untouched.
You can fix this by:
- Make revisions to your website fewer, or disable them altogether.
- Remove unnecessary revisions from your site’s database by cleaning it out periodically.
Are there any questions you still have related to WordPress post revisions? Feel free to comment and let us know!
If you enjoyed this tutorial, then you’ll love Rovity and our fast-growing premium shared hosting on the cloud. Check our subscription plans.