DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Post revisions are super useful sometimes, but from time to time you might want to clean your database. Here’s a super easy way to delete all posts revisions.

Open you functions.php file and paste the following code:

$wpdb->query( "
DELETE FROM $wpdb->posts
WHERE post_type = 'revision'
" );

Save the file and open your blog homepage to run the code. Once done, there’s no need to keep the code snippet in your functions.php file, as it will always delete all post revisions. So simply remove it.

Thanks to Hardeep Asrani for the tip!

One Comment

  1. I think it will be better to simply limit the amount of post revisions that are stored.

    http://www.paulund.co.uk/change-the-amount-of-wordpress-post-revisions-stored

Leave a Comment

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