Easily delete WordPress post revisions using your fuctions.php file

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!

Leave a Reply

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