WPKube

How to Disable and Remove Old Post Revisions in WordPress

A post revision or two won’t take up a ton of space.

But they do start to add up after a while and 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, removing old post revisions from your WordPress site is an available option, and in this article I’ll show you how to do just that.

Before we get started with the tutorial, let me run some quick facts by you.

How Much Space Do Post Revisions Occupy?

Let’s put things into perspective.

You’re a WordPress user and devoted blogger. Adding, editing, saving, and publishing posts is part of your routine. A regular post, on its own, doesn’t take up a ton of space but when it starts multiplying you’ve got yourself a problem – the same post is saved to your database every single time you hit the Save button.

I tend to make a ton of minor corrections and edits on my posts after adding the first draft to the WordPress post editor and save the post every time. On average, one of my posts is saved to the database nearly 25 times by the time I hit Publish.

25 post revisions certainly don’t take up a ton of space but if you multiply it by the number of posts you have on your site then that’s not negligible.

Impact of Post Revisions on Site Performance

A common myth that’s been floating around is that post revisions have a negative impact on the speed of your WordPress site. The reason you’ll hear to back up this theory is that because post revisions take up space on the database, the SQL queries running in the backend have more data to go through and thus present results slower.

This myth is simply just that. A myth.

When it comes to site speed, WordPress post revisions do NOT have a negative impact on your site’s performance. This is because the SQL queries don’t run on post revisions nor do they retrieve revisions.

In short, the only negative impact post revisions have is that they take up a ton of space on the database. And if you’re already low on space, removing post revisions can clear up some much needed space.

Now that we agree that old post revisions do in fact take up database space that we want freed up, let’s go over some quick methods to remove them.

How to Disable Old Post Revisions

In this section, we’ll walk through a tutorial on how to disable old post revisions permanently and how to set user-defined restrictions on them in case you want to save a couple of revisions per post.

Disabling/Re-enabling 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 );

Limiting Post Revisions

If you’re anything like me, 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. Add the following line to your wp-config.php file:

define( ‘WP_POST_REVISIONS’, 3 );

What this line does is that it saves the 3 most recent post revisions instead of all of them i.e. the older ones are automatically deleted once newer versions are saved. You can replace the number 3 with another integer depending on your preference.

Setting the Auto-Save Interval

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) but by adding this line it’ll save them every ten minutes (600 seconds). This automatically reduces the number of post revisions that are stored to 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. Some popular choices are WP-Sweep and WP Revisions Control.

It’s important that you understand that the techniques we covered disable post revisions from being saved for future posts. What about the past revisions?

How to Remove Old Post Revisions

In this section we’ll cover two methods of permanently removing old post revisions from your WordPress site’s database.

Those of you who are familiar (and comfortable) with SQL queries can go with the first method. But if you’d prefer using a plugin then go ahead and skip right down to the second method.

Method 1: Deleting Post Revisions Using Code

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). I mean, you’re trying to save space and installing a plugin goes against that.

In order to delete all of your past post revisions from your site’s database, go to your site’s PHPMyAdmin and execute the following SQL query:

DELETE from wp_posts WHERE post_type = “revision”;

This SQL query removes all posts from your database that have post_type = “revision”. Some webmasters might want to create a backup of their database prior to running this query as an added security measure. In my personal opinion, it’s always best to make backups of your database before you make drastic changes to it.

Method 2: Deleting Post Revisions Using A Plugin

Although deleting post revisions from your WordPress site can be accomplished by running a single SQL query, some webmasters will 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 they’re not comfortable with programming.

Revision Control

Revision Control enables users to gain finer control over their WordPress site’s post revision system. With its simple one-click functionality, users can choose to disable or enable post revisions without have to get into the nitty gritty code.

The plugin also enables users to set limits on the number of post revisions that are saved to the database. Revision Control’s fine-tuned system lets webmaster disable, enable and set restrictions for either posts or pages depending upon their preference.

Better Delete Revision

The Better Delete Revision plugin removes redundant post revisions from your WordPress site’s database in addition to the meta-data that is associated with them including tags and relationships. The plugin is careful not to mess with your site’s published content or posts that have been scheduled to be posted.

Most webmasters, even those that are familiar with WordPress programming, often choose to remove post revisions using this plugin because it also performs some light database optimization.

Both of these plugins are available for free.

Wrapping It Up

Post revisions don’t slow your site down or pose as an issue for user experience. They do, however, start to take up a lot of space on your site’s database after a while.

If you’ve been publishing posts on your WordPress site for a few years now then removing the old post revisions will clear up a significant amount of space for you on your database.

On the other hand, if you’re just starting out as a WordPress blogger, then you can leverage the first part of this tutorial and disable old post revisions.

We hope you our tutorial helped you learn how to Disable and Remove Old Post Revisions in WordPress. You may also want to see our post on 5 things you need to do to keep your WordPress site running Smoothly.

Which method are you most comfortable with for disabling/removing old post revisions? Is there another method you use? Can you recommend a plugin that gets the job done? Let us know in the comments section below!