How to Handle Post Revisions in WordPress

Post revisions in WordPress are a great idea in principle, but I can’t stand them and the fact you can’t disable or change the save interval via the Settings page is a real oversight. Not only do they take up unnecessary space in the database they also slow down your site because of it. How many times have you spent a fair amount of time editing a new post because of a spelling error or changing a sentence?

If you’re like me, more than a few.

Having revisions save every single time you you do something may not be your cup of tea so here are a couple of things you can do to change their behavior or disable them altogether.

Disable WordPress Post Revisions

Add this line to your wp-config.php file, located in the WordPress root directory, to disable revisions.

define('WP_POST_REVISIONS', false );

Limit WordPress Post Revision Count

If you just prefer to just limit how many revisions WordPress maintains add the following to your wp-config.php file, located in the WordPress root directory. Just change the value to the number you want to maintain.

 define('WP_POST_REVISIONS', 10 ); 

Delete Existing WordPress Post Revisions

To delete any past revisions you will need to delete those directly from the database. To do this you will need to access your database via phpMyAdmin or a SQL Editor and running the following query.

DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';

Hopefully in a future version of WordPress these options will get added to the Settings to make them easier to deal with.