Skip to content Skip to sidebar Skip to footer

How to Limit Post Revisions in WordPress

Last updated on January 17th, 2025

Introduction

WordPress is a powerful platform for creating and managing content, but it comes with features that can slow down your website over time. One of these features is post revisions. Every time you save a post or page in WordPress, it creates a revision, which can quickly accumulate and bloat your database. Limiting post revisions can help improve your website’s performance and reduce unnecessary database storage. In this article, we will show you how to limit post revisions in WordPress to keep your site running smoothly and efficiently.

1. What Are Post Revisions in WordPress?

Post revisions in WordPress are a feature that allows you to track and store every change made to your posts or pages. Each time you update your content, WordPress saves a revision of that content. This can be helpful if you want to revert to an earlier version of your post, but over time, these revisions can accumulate, making your WordPress database larger and potentially slowing down your website.

While revisions are helpful for content management, too many revisions can result in database bloat, affecting performance and speed.

2. Why Should You Limit Post Revisions?

There are several reasons why limiting post revisions is a good practice for WordPress websites:

  • Improved Website Speed: The more revisions your database stores, the larger it becomes. A bloated database can lead to slower site performance. Limiting revisions helps to keep your database lean and efficient.
  • Better Database Management: Storing fewer revisions reduces the size of your database, making it easier to back up and manage.
  • Faster Backups: Smaller databases make backups faster and more reliable. When you limit revisions, you help speed up the backup process and ensure that your site is easy to restore if needed.

3. How to Limit Post Revisions in WordPress

There are a few simple ways to limit post revisions in WordPress. Here are the most common methods:

1. Edit the wp-config.php File

The most common way to limit revisions is by editing the wp-config.php file in your WordPress root directory. This method allows you to set a maximum number of revisions for each post.

  • Access your WordPress root directory using an FTP client or file manager in your hosting control panel.
  • Locate the wp-config.php file and open it for editing.
  • Add the following line of code before the line that says, “/* That’s all, stop editing! Happy publishing. */”:
php
define('WP_POST_REVISIONS', 5);
  • This will limit the number of revisions to 5 per post. You can change the number to any value you prefer.
  • Save the changes and upload the file back to the server.

2. Use a Plugin to Limit Revisions

If you’re not comfortable editing code, you can use a plugin to limit post revisions. There are several plugins available that allow you to easily manage post revisions in WordPress. Some popular ones include:

  • WP-Optimize: This plugin allows you to clean up and optimize your WordPress database, including limiting the number of post revisions.
  • Revision Control: This plugin allows you to set limits on the number of revisions per post and manage how many revisions WordPress keeps.

After installing and activating the plugin, you can adjust the settings to limit revisions based on your preference.

3. Manually Delete Old Revisions

While limiting revisions prevents WordPress from creating too many in the future, you may already have a lot of old revisions stored in your database. You can manually delete these revisions using the following methods:

  • Using a Plugin: Plugins like WP-Optimize or Advanced Database Cleaner allow you to delete old post revisions easily.
  • Using phpMyAdmin: If you’re comfortable using phpMyAdmin, you can run an SQL query to delete revisions directly from your database.

For example, use this query in phpMyAdmin to delete all revisions from your database:

sql
DELETE FROM wp_posts WHERE post_type = "revision";

Make sure to back up your database before running any SQL queries.

4. Best Practices for Managing Post Revisions

  • Set an Appropriate Limit: While limiting revisions is important, setting the limit too low may not give you enough backup options. A good rule of thumb is to limit revisions to 5-10 per post.
  • Clean Up Regularly: Periodically clean up your database to remove old revisions that are no longer needed. This helps maintain optimal performance.
  • Backup Your Database: Always back up your WordPress site before making any changes to your database or code. This ensures you can restore your site if anything goes wrong.

Conclusion

Limiting post revisions in WordPress is an important step in optimizing your website’s performance and managing your database efficiently. By reducing the number of revisions stored, you can ensure faster site speed, smoother backups, and easier database management. Whether you choose to edit the wp-config.php file, use a plugin, or delete old revisions manually, limiting revisions is an effective way to keep your WordPress site running at its best. Start managing your post revisions today and enjoy a faster, more optimized WordPress experience.

Leave a comment