Site icon CodeRevolution Knowledge Base

Easily delete WordPress post revisions using your fuctions.php file – CodeRevolution

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!

Exit mobile version