Blog / WordPress/ How to Disable Auto-save and Revisions in WordPress

How to Disable Auto-save and Revisions in WordPress

WordPress's auto-save and revision features are designed to prevent content loss, but they can generate significant redundant data for many websites, especially those with limited database space or those pursuing optimal performance. This article explains several methods to disable these features, including using plugins and code modifications.

Method 1: Using a Dedicated Plugin (Recommended for Beginners)

Using a plugin is the simplest and safest approach, requiring no core code changes.

Recommended Plugin: Disable Post Revision

This is a lightweight, well-maintained plugin with a specific focus.

  1. In your WordPress admin dashboard, go to 'Plugins' → 'Add New'.
  2. Search for 'Disable Post Revision'.
  3. Click 'Install Now' and then 'Activate'.

Once activated, this plugin automatically disables revisions for posts and pages and significantly reduces the auto-save frequency.

Method 2: Disabling via Code (For Developers)

If you prefer not to install an extra plugin or want more granular control, you can modify your theme's functions.php file.

1. Completely Disable Revisions

Add the following code to the end of your current theme's functions.php file:

// Completely disable post revisions
define('WP_POST_REVISIONS', false);

2. Limit the Number of Revisions

To keep only a limited number of recent revisions (e.g., the latest 5), set a numerical limit:

// Limit revisions to 5
define('WP_POST_REVISIONS', 5);

3. Adjust the Auto-save Interval

WordPress auto-saves every 60 seconds by default. You can extend this interval (in seconds) with the following code:

// Set auto-save interval to 300 seconds (5 minutes)
define('AUTOSAVE_INTERVAL', 300);

Important: Always back up your functions.php file before editing. It's recommended to use a child theme for modifications to prevent code loss during theme updates.

Method 3: Global Configuration via wp-config.php

The most thorough method is to edit the wp-config.php file in your WordPress root directory. Add the following code just before the line that says /* That's all, stop editing! Happy publishing. */:

// Disable revisions and set auto-save interval
define('WP_POST_REVISIONS', false);
define('AUTOSAVE_INTERVAL', 600); // Set to 10 minutes

This method applies to the entire site and has the highest priority.

Important Considerations & Best Practices

  • Database Cleanup: Disabling revisions does not remove existing revision data from your database. To clean it, use a database optimization plugin like 'WP-Optimize'.
  • Trade-offs: Disabling auto-save increases the risk of losing unsaved content due to browser crashes or accidental closure. Choose based on your writing habits and site stability needs.
  • Test Environment: Before making significant changes (especially code edits) on a live site, test them first on a local or staging environment.

Using these methods, you can effectively manage WordPress's auto-save and revision features to optimize your database and improve site performance.

Post a Comment

Your email will not be published. Required fields are marked with *.