Revisions are simply the older drafts of your post, saved in the WordPress database. To delete WordPress old revisions install the WP-Sweep plugin. Then go to Tools > Sweep and clean the revisions. You can also limit revisions or just disable them, using the methods below.
Revisions are a great way to undo changes in WordPress posts. Although Some of these revisions will never be used and they’re only wasting database space. A single post in WordPress can have several revisions.
Every time you make changes to your post, a new revision gets created and stored in your database. As we said, the more posts you have, the more revisions there will be. So to empty out your database it’s crucial to delete some of your revisions.
Old websites don’t need to save their revisions. Imagine a website with 1000 pages or posts, if each of them has several revisions, imagine how much of your database you have to dedicate to these revisions. In this article, we will discuss different ways to delete WordPress revisions.
How to Delete All WordPress Old Revisions?
Most WordPress tasks can be easily done by installing a plugin. To delete WordPress revision, you can install the free WP-Sweep plugin.
Remember to get a backup of your WordPress database in case anything goes wrong.
To delete WordPress old revisions take these steps:
1. Go to Plugins > Add New
2. Search for WP-Sweep, install and activate it
3. Go to Tools > Sweep
4. In front of ‘Revisions' click on Sweep
How to Disable WordPress Revisions with Code?
To disable WordPress revisions forever, you will have to head over to your WordPress dashboard and locate the wp-config.php file from your WordPress directory and copy and paste the code below to the top:
define( 'WP_POST_REVISIONS', false );
This code will disable your WordPress revisions and they won’t be stored in your database. The “false” value disables it. In the future, if you wish to enable your WordPress revisions simply change the value to “true” and save it.
define( 'WP_POST_REVISIONS', true );
To delete all of your revisions from your database you need to run this MySQL query:
DELETE FROM `wp_posts` WHERE `post_type` = "revision" AND `post_name` LIKE "%revision%"
This code will delete WordPress revisions stored in your database.
How to Limit WordPress Revisions?
Instead of fully disabling or deleting your revisions, you may want to limit the number of revisions stored on your database.
First, open your wp-config.php file, because you will need to add some code to it. Copy and paste the code below above “ABSPATH”. If it’s not copied above “ABSPATH” it will not work.
You can replace “3” with any number you would like. For example, if the number is set to 3, your posts will only have 3 revisions and any new revisions will replace old ones.
This option is very beneficial for people who have limited database space and still want to use this feature. You can also use “Perfmatters” plugin to limit the number of revisions per post.
How to Change Autosave Interval in WordPress?
You can also change your autosave interval. If you wish to set an exact time, you could do so by adding the code below to your wp-config.php file:
define('AUTOSAVE_INTERVAL', 600 );
By default, autosave is 1 minute in WordPress. You can change that number. Here we have changed it to every 10 minutes. This will autosave your revisions every 10 minutes.
Although, this code cannot delete your old revisions stored in your database. Auto-delete revisions can be very useful when you don’t have access to the internet. You can use WP-Revisions control and WP-Sweep for more features.
How to Delete WordPress Revisions from Database?
Although, running a MySQL query is very fast and simple but still some users prefer to use plugins. This way you don’t need any programming knowledge. Thus, the risk of you breaking your database is slim. The Revision Control plugin allows its users to have more control over their WordPress revisions.
Users can disable or activate revisions with one simple click. It also allows its users to manage the revisions stored in their database.
Better Delete Revision is also another plugin that can be used to delete old WordPress revisions stored in your database. Most webmasters and programmers use this plugin. Both of these plugins are totally free to use.