As a small business owner, you might never think that database management could keep you up at night. But it’s something I experienced on my own personal site, wondering why it had slowed to a crawl. The reason being lots of post revisions eating up server resources.
Every time you save a draft or update a published post, WordPress automatically saves a revision. This is incredibly useful in case you need to go back to a previous version of your blog post.
However, these post revisions can accumulate over time, bloating your WordPress database. That’s why it is important to limit the number of post revisions and optimize your site’s database.
In this article, I’ll show you how to limit post revisions in WordPress using a simple method.
Why Limit Post Revisions in WordPress?
Post revisions are an essential feature in WordPress, as they help you go back to a previous version of a blog post in case something goes wrong.
You can easily restore earlier drafts and track changes you’ve made over time by viewing the revisions in the content editor.
![View revisions in content editor](https://wpcode.com/wp-content/uploads/2025/02/view-revisions-in-content-editor.png)
While revisions are beneficial, keeping every single revision since the start of your blog might not be necessary.
That’s because they can lead to database issues, like:
- Database Size: Each revision is stored in your database. If you frequently update content or have a large team of writers, the number of revisions can quickly grow. A larger database takes up more storage space and can slow down database operations.
- Potential Performance Issues: While the performance impact of revisions is often negligible on modern servers, a very bloated database can contribute to slower loading times and backend operations, especially on shared hosting with limited resources.
- Database Clutter and Backup Size: A database filled with unnecessary revisions becomes cluttered and harder to manage. Furthermore, larger databases mean larger backup files, which take longer to create, store, and restore.
That said, let’s look at how you can easily limit post revisions in WordPress.
Limiting Post Revisions in WordPress
You can limit post revisions on your website by adding a code snippet to the wp-config.php file. However, many users are not comfortable editing code. And the slightest mistake can break your site’s functionality and appearance.
An easier solution is to use WPCode, the best WordPress code snippets plugin. It helps you insert and manage custom code snippets on your website, and comes with a pre-built code snippet library. You can simply insert the snippet for limiting post revisions in WPCode with 1-click.
To get started, you can use the WPCode Lite version for free, and it includes the limit post revisions snippet. However, there is also a WPCode Pro version which offers more features like AI Snippet Generator, eCommerce integrations, Conversion Pixels, and more.
First, you’ll need to go to Plugins » Add New Plugin from your WordPress dashboard and search ‘WPCode’ in the search bar.
![Install WPCode lite version](https://wpcode.com/wp-content/uploads/2024/09/install-wpcode-1-1024x436.jpg)
From here, you can click the ‘Install now’ button and then activate the plugin. If you need help, then please see this guide on how to install a WordPress plugin.
Once the plugin is active, you’ll need to go to Code Snippets » Add Snippet from the WordPress admin panel.
![Select limit post revisions snippet](https://wpcode.com/wp-content/uploads/2025/02/select-limit-post-revisions-snippet-1.png)
Next, you can search for the ‘Limit the Number of Post Revisions’ snippet using the search bar or head to the ‘Admin’ tab to select the custom code snippet.
After that, you should see the code editor with the snippet already loaded.
![View post revisions code snippet](https://wpcode.com/wp-content/uploads/2025/02/view-post-revisions-code-snippet.png)
This snippet will restrict the post revisions to 20 by default. However, you can change it to any number you want. Keeping around 3 to 5 revisions per post is generally a good balance. It provides enough history to restore previous versions if required without excessively bloating your database.
On the other hand, if you want to completely disable post revisions, then you set the number to 0. This way, your post revisions won’t be stored in the database and the option to view them in the content editor will also be removed.
Next, you can scroll down to the ‘Insertion’ section and select where the code will be inserted. By default, WPCode will automatically execute the code everywhere on your site.
![How to insert code in website](https://wpcode.com/wp-content/uploads/2024/12/how-to-insert-code-in-website.png)
After that, you can scroll to the top of the page and click the toggle to make the snippet Active.
From here, simply click the ‘Update’ button.
![Enable post revisions snippet](https://wpcode.com/wp-content/uploads/2025/02/enable-post-revisions-snippet.png)
That’s it, you’ve successfully limited the number of post revisions on your website.
Remove Existing Post Revisions in WordPress
Limiting post revisions will stop your database from being cluttered. That said, what if you need to remove existing post revisions in bulk without having to go through each post individually?
The easiest way to do that is by using a free plugin like WP-Optimize. It will help you optimize your database by deleting old revisions, drafts, and more.
Note: When the code snippet in WPCode is active, WordPress will limit the post revisions to the number you set in the snippet and delete older revisions. For example, if you’ve set the number of post revisions to 20, then only the most recent 20 revisions will be saved in the database and previous versions will be removed.
First, you’ll need to install and activate the WP-Optimize plugin. If you need help, then please see our guide on how to install a WordPress plugin.
Once the plugin is active, you can head to WP-Optimize » Database from the WordPress dashboard and go to the ‘Optimizations’ tab.
![Clean all post revisions](https://wpcode.com/wp-content/uploads/2025/02/clean-all-post-revisions.png)
After that, you can select the Clean all post revisions option and click the ‘Run optimization’ button. The plugin will remove old post revisions from your website.
We hope this article helped you learn how to limit post revisions in WordPress. You may also want to see our guide on how to add floating social media icons in WordPress and how to insert ads in your post content in WordPress.
If you need help, then feel free to contact us or leave a comment below. And don’t forget to follow us on X (formerly known as Twitter) and subscribe to our newsletter for all the latest updates.