Deleting Multiple Pending Posts and Post Revisions Instantly from WordPress Using MYSQL Scripts

Have you ever tried deleting multiple posts (more than 500posts) from the WordPress admin panel before? If you’ve tried you’ll know that it fails! Yes it fails hopelessly.

I know that there are lots of Bulk delete WordPress plugins out there in the WordPress repository that can do the job. But how do you delete multiple pending posts, post revisions if there are way too many posts? (Say more than 2000 posts)

I’m not exaggerating things here guys. I had this exact problem myself and some of my friends who had guest posts enabled in WordPress faced the same issue too. So HOW do you delete multiple posts instantly in WordPress? The bulk delete plugin timed out on me and I was left wondering how else can I get the deletion work done easily?

Then I realized it ‘MySQL’! Yes, MySQL can do this for me and within no time at all. It took me less than 5 minutes to delete all the pending (spam) posts from WordPress. So this is me contributing to the WordPress ecosystem by sharing how I achieved what I needed!

>> Login to your MYSQL and select the SQL tab from the MYSQL window.

 

Step1 – Searching and deleting all Pending Posts in Bulk:

SELECT * FROM `wp_posts` WHERE `post_status` LIKE 'pending'

This fetches all the posts that are NOT yet published and which are in the pending state.

DELETE FROM `wp_posts` WHERE `post_status` LIKE 'pending';

This SQL query removes all the posts that are currently in pending state.

SELECT * FROM `wp_posts` WHERE `post_status` LIKE 'pending';

Now run the select statement again to see if the deletion of pending posts worked.

Once you’ve removed all the pending posts from WordPress. You would need to check the revisions made on those posts. These still do exist in WordPress and would consume some space.

Step2 – Searching and deleting all Post Revisions Posts in Bulk:


Thanks bacsoftwareconsultine for the image

Select * FROM wp_posts WHERE post_type = "revision";

Fetches all the posts that are currently under revisions state.

DELETE FROM wp_posts WHERE post_type = "revision";

Deletes all the post revisions.

Select * FROM wp_posts WHERE post_type = "revision";

Running the select statement to see if it worked!

Warning: To be tried only if you know a little bit of SQL (Structured Query Language) or you might end up screwing up your WordPress setup..

Need help? or Have you faced any other similar issues in bulk deletion of content from WordPress? Share your comments below!

2 thoughts on “Deleting Multiple Pending Posts and Post Revisions Instantly from WordPress Using MYSQL Scripts”

  1. Hi I have tried this but by mistake i have changed the sql database password, now my site is not opening what should i do. please help me.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>