In an earlier article, I’d talked about some WordPress maintenance tasks that you should do regularly. One of them was limiting the number of post revisions that WordPress saves by default. However, in that article, I’d mentioned a plugin you could use that did several different maintenance tasks at once from the same interface. But if you just want to know how to limit the number of post revisions in WordPress without a plugin, this tutorial is for you!
WordPress Saves Unlimited Revisions by Default
Whenever you make a change and save either a published post or a draft, WordPress saves a copy of the revision in its database, enabling you to revert to it whenever you want. Here’s a screenshot showing 10 post revisions that I made to a test post:
This number increases without limit as time goes by, and you can imagine that if you have lots of posts on your site, the sheer weight of the revisions will keep piling up. I don’t think they take up too much storage space, but why have the remnants of posts long gone? It creates unnecessary rows on in your tables, and it smacks of poor housekeeping.
Instead, what we want to do, is to put a limit on this useful feature – we don’t want to disable it entirely. I find a limit of 3 to be pretty good. But you can go ahead and set it higher – to maybe 10 if you want. Anything as long as it’s not infinite!
Here’s how we can limit the number of post revisions that WordPress saves by default.
Updating the wp-config.php File
In the root directory of your blog, there’s a very important file called “wp-config.php”. This is where all the access information for your site’s databases is stored, and it’s also where WordPress keeps a lot of important configuration data. We can modify this file to include a special variable that instructs WordPress to keep a specific number of post revisions. The name of the variable is:
WP_POST_REVISIONS
To open wp-config.php, go to your web hosting’s admin panel (usually cPanel), and open the file manager. Now navigate to the WordPress home directory, locate wp-config.php and open it. But before you make any changes, be sure to take a backup if this is your first time editing the wp-config.php file. It’s a very delicate file, and you can completely hose your WordPress site if you’re not careful!
There, you insert the following line:
define( ‘WP_POST_REVISIONS’, 3 );
Here’s a screenshot of where you can place it:
Make sure you put this line above the line which says “That’s all, stop editing! Happy blogging”. Don’t forget to include the semi-colon at the end of the statement. Save your changes, and you’re done!
Verifying that the Post Revisions Limitation is Working
Once you’ve made the change above, go to any post and save your changes. The changes for each post won’t take effect until you’ve tried to save it at least once. But as soon as you click the “save” or “update” button, the number of post revisions will be restricted to the number you set in wp-config.php. Here’s a screenshot showing that I now have only 3 post revisions as opposed to 10 from the same post I showed earlier:
And that’s it! With a simple line change, you’ve implemented a site-wide policy of limiting WordPress post revisions without needing to install a plugin. It’s a neat solution that works very nicely. I hope you found this useful!

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!
Leave a Reply