Deleting WordPress post revisions

Here is another quick code snippet that might help you clean up your database a little. As you may know WordPress saves copies (actually diff’s) of your posts, so that you can easily roll back to a certain version of a page if make a mistake. Overtime this might get to be quite a bit of data, especially for large sites.

I tend to do this when launching a new site, as there might be placeholder information that might confuse people if seen.

Query to delete WordPress revisions

If you run the following query, all previous stored revisions will be removed from the wp_posts table.
DELETE FROM wp_posts WHERE post_type = "revision";

Delay autosave interval

WordPress by default will auto save your post every 60 seconds, you can extend this by editing wp-config.php file in your root folder of your WordPress install. The following code will push this interval to 5 minutes.
define('AUTOSAVE_INTERVAL', 300 ); // seconds

Disable post revisions

Should you want to disable post revisions completely (not that we recommend it) you can add this line to your wp-config.php file.
define('WP_POST_REVISIONS', false );

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.