EN / ZH
WordPress Tip: Disable and Delete Post Revisions

WordPress Tip: Disable and Delete Post Revisions

The revision history feature was apparently added to WordPress starting from version 2.6. I’m not particularly fond of the term “revision history,” so I prefer to call it “edit history.” In my opinion, this feature is essentially useless for most personal blogs — a classic case of something that’s a shame to throw away yet serves no real purpose. Moreover, revision history stores your edit records in the database, which causes the database to become bloated and wastes resources. So here’s how to disable and delete WordPress revision history, though there are plenty of tutorials on this topic already.

1. Disable WordPress Post Revision History

Open the wp-config.php file in your WordPress root directory and add the following code:

define('WP_POST_REVISIONS', false);

2. Delete Existing WordPress Post Revision Records

As mentioned above, WordPress post revision records are stored in the database, so we need to delete the relevant entries from MySQL. Execute the following SQL statements (just run them directly):

DELETE FROM wp_postmeta WHERE post_id IN (SELECT id FROM wp_posts WHERE post_type = 'revision');
DELETE FROM wp_term_relationships WHERE object_id IN (SELECT id FROM wp_posts WHERE post_type='revision');
DELETE FROM wp_posts WHERE post_type='revision';

OK, that’s it! After completing these two steps, WordPress will no longer generate revision history when you write posts, and your database won’t keep growing unnecessarily.