If you have a blog that runs on WordPress you’ve probably noticed how every time you make a change to a post or page WordPress creates a copy of the previous version and stores it in the WordPress database.
These copies are called “Post Revisions”, and they can come in real handy when you want to revert back to an older version of a post. Simply select the version you want to revert to and the WordPress editor will make it happen.
But there’s a problem with these Post Revisions. Every time one is created it basically creates a new copy of the post you’re working on and stores it in the WordPress database.
If you tend to make lots of changes to your posts like I do (I typically end up making dozens of them before a new post goes live), your WordPress database ends up containing numerous “copies” of the same posts.
That’s a bad thing because the larger your WordPress database is, the slower your blog will perform. And as you probably know, Google is now taking page-load times into account when ranking web pages in their search results.
By default, WordPress doesn’t limit the number of post revisions it will create for each post or page. It will just keep on creating new copies every time you click the “Save Draft” or “Publish” button.
Luckily, there are a couple of easy ways to limit the number of post revisions WordPress will create. In fact, you can even disable them altogether if you want to.
To change the number of Post Revisions stored by WordPress…
As with most things WordPress, the easiest way to limit the number of post revisions is to use a plugin. Simply follow the steps below if you would prefer going that route:
1 – Log in to your WordPress Dashboard.
2 – Click Plugins>Add New.
3 – Type limit post revisions into the search box. You should now see a bunch of plugins to choose from.
4 – Select the plugin you wish to use and click the Install Now button.
Note: Most “limit post revisions” plugins allow you to set the maximum number of post revisions that WordPress will be allowed to create for a given post or page by changing a setting on the plugin’s “Settings” page. For what it’s worth, I keep my maximum number set to 3.
That’s all there is to using a plugin to limit the number of post revisions WordPress will create on your blog.
All of the above being said, I prefer to avoid using a plugin when there are other ways to achieve the same result, for two reasons:
1 – Every plugin that’s active on a blog slows the blog down by a bit.
2 – Every plugin that’s active on a blog is another potential entry point for a hacker to take control of your blog.
If you prefer avoiding plugins when possible as well, you can limit the number of post revisions on your blog by adding just one line to your blog’s primary configuration file (wp-config.php).
Important: If you decide to go this route, do so carefully because editing any of your blog’s back-end files isn’t a risk-free endeavor.
One simple misplaced character can wreak all kinds of havoc with your blog. In fact, one simple error can prevent your blog from loading at all!
This is why I always recommend that you back up all of your blog’s files before making any changes to any of them. Failure to do so can potentially cause a lot of grief.
Now that we have that dire warning out of the way, follow the steps below to limit the number of post revisions allowed on your blog by adding a snippet of code to your blog’s wp-config.php file:
1 – Use an FTP program like FTP Commander or Filezilla (both of these programs are free) to download a copy of the wp-config.php file from your blog’s web server to your computer. You will find wp-config.php in the root directory of your blog’s WordPress installation.
2- Open the downloaded file in Notepad (or your favorite plain text editor) and immediately save it with the name wp-config-bak.php. That will create a backup copy of the original file just in case something goes wrong and you have to restore the original configuration file.
3 – Close the current document by and open wp-config.php once again.
4 – Add the following line near the top of the file:
define( ‘WP_POST_REVISIONS’, 3 );
Note: The 3 in the line above limits the number of post revisions to 3. You can change that number if you want WordPress to create a different number of post revisions on your blog.
Here is a partial screenshot showing where I placed the new line inside my own wp-config.php file:
5 – Save the file.
6 – Use your FTP program to upload the altered wp-config.php file to your server. Make sure you FTP the file into the root directory of your blog’s WordPress installation (i.e. the same directory where you found it in step 1 above).
That’s all there is to it. Your WordPress installation should now limit the number of post revisions to the number you used in step 4 above.
To disable Post Revisions altogether…
If you would rather disable post revisions altogether you can easily do that by replacing the number 3 with the word false. In other words, this is the line you would insert in step 4 above:
define(‘WP_POST_REVISIONS’, false );
Again, just add that line to your wp-config.php file by following the instructions above to prevent WordPress from creating any post revisions at all.
Checking your blog after the changes have been made…
Now that you have made the changes mentioned above you should check your blog to make sure everything still works as expected.
If your blog fails to load in the browser (i.e. you get an error message) or if things look out of whack, that means there is an error in the altered configuration file.
You can easily get your blog back to working correctly by replacing the altered wp-config.php file with the unchanged original version. Here’s how:
1 – Rename the altered wp-config.php file to wp-config-not-working.php.
2 – Rename the file you saved earlier as wp-config-bak.php to wp-config.php.
3 – FTP the wp-config.php file to your server to replace the faulty configuration file. Again, make sure you FTP the file into the proper directory. That should get your blog back to working correctly again.
4 – At this point you can either check the wp-config-not-working.php file to see if you can spot the error or simply use the plugin method of limiting post revisions that I mentioned earlier.
If you decide to debug the faulty configuration file and you are able to spot the error, simply rename it back to wp-config.php and FTP it to the server once again.
Bottom line…
Keeping the number of post revisions to a minimum will help ensure a faster-loading and more secure WordPress blog.
Bonus tip #1: This post explains how to easily keep your blog free of broken links.
Bonus tip #2: Want to make sure you never miss one of my tips? Click here to join my Rick’s Tech Tips Facebook Group!
If Facebook isn’t your cup of tea, I invite you to sign up for my Rick’s Daily Tips Daily Update Newsletter.
Want to ask Rick a tech question? Click here and send it in!
If you found this post useful, would you mind helping me out by sharing it? Just click one of the handy social media sharing buttons below.