Site icon DopeThemes

Disable WordPress Revisions – Limit WP Revisions

Disable WordPress Revisions - Limit WP Revisions

WordPress revisions are a useful feature that automatically saves copies of your content each time you make a change. While this is helpful in many cases, it can also lead to a bloated database over time, especially if you’re frequently editing posts or pages. If you’re looking to either disable or limit the number of revisions in WordPress, you can easily do so by adding a few lines of code to your wp-config.php file.

In this tutorial, we’ll show you how to both disable WordPress revisions completely and how to limit the number of revisions to a specified amount.

Step 1: Open Your wp-config.php File

The first step is to locate and open your wp-config.php file. This file is located in the root directory of your WordPress installation, and it controls various important settings for your WordPress site. You can access it via FTP, your hosting control panel (such as cPanel), or directly through file management tools in your hosting dashboard.

Step 2: Disable WordPress Revisions

If you want to disable WordPress revisions entirely, simply add the following code to your wp-config.php file. This will prevent WordPress from saving any post or page revisions:

// Disable WordPress Revisions
define( 'WP_POST_REVISIONS', false );
Explanation:

Important: Disabling revisions means you will not be able to revert back to previous versions of your content if changes are made. Use this option with caution if you frequently update or edit content.

Step 3: Limit the Number of WordPress Revisions

If you don’t want to disable revisions completely but want to limit the number of saved revisions to avoid cluttering your database, you can set a limit by adding this line of code to your wp-config.php file:

// Limit WordPress Post Revisions - recommended settings ( minimum: 2 | maximum: 5 )
define( 'WP_POST_REVISIONS', 3 );
Explanation:
Recommended Settings:

Why Should You Limit or Disable Revisions?

WordPress revisions can be very helpful in restoring previous versions of posts or pages. However, storing too many revisions can increase the size of your database, which can slow down your site’s performance. If you’re running a large site or frequently making changes to content, limiting or disabling revisions can help you maintain a lean and optimized database.

Key Considerations:
Conclusion

By adding a simple line of code to your wp-config.php file, you can easily control how WordPress handles post revisions. Whether you choose to disable them completely or limit them to a manageable number, adjusting this setting can help optimize your site’s performance and prevent unnecessary database bloat. For most users, limiting revisions to 2-5 is a good balance between functionality and performance.

Make sure to always keep a backup of your site and database before making any changes to core WordPress files like wp-config.php. This will ensure that you can easily restore your site if anything goes wrong during the process.

Next: PHP 8 create_function Replacement

Exit mobile version