WordPress Post Revisions: disable, autosave, limit, delete

Managing post revisions is crucial for optimizing your WordPress site’s performance and database efficiency. By fine-tuning revision settings, you can streamline your workflow and ensure your database remains clutter-free.

Disable Post Revisions via wp-config.php

To disable post revisions completely, edit the wp-config.php file. Insert the code snippet:

define('WP_POST_REVISIONS', false);

Adjust Autosave Intervals via wp-config.php

To avoid losing work in case of unexpected errors or user mistakes, you can enable interval auto-saving. This feature saves your post drafts at regular intervals, providing a safety net in case of data loss. To enable interval auto-saving, you can add the following code to your wp-config.php file:

define('WP_POST_REVISIONS_INTERVAL', 60);
// Set the interval to 60 seconds

This code enables post revisions and sets the interval to 60 seconds.

Limiting the Number of Post Revisions

If you want to limit the number of revisions created for each post, you can do so by adding the following code to your wp-config.php file:

define('WP_POST_REVISIONS', 3);

Delete All Revisions via PHPMyAdmin:

If you want to delete all revisions from your post revisions via PHPMyAdmin, you can do so by using the following SQL query:

DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'revision' AND post_name LIKE '%revision%');

Effectively managing post revisions in WordPress is essential for maintaining a clean and efficient database. By implementing these techniques, you can optimize your site’s performance and enhance your overall user experience.