I have around 2000 posts under a custom post type storelocations
. Deleting them from WordPress admin takes a lot of time.
How to delete all the posts from this custom post type from database using mySQL command. Here is my approach:
DELETE FROM 'wp_posts' WHERE 'post_type' = 'storelocations'
But I guess the post also have some data in wp_postmeta
and some other
tables maybe. And I guess I should delete data from there too.
So, may I know which tables have the data for a post. And what command I should run to clear them.
Another doubt that I have is: why deleting the posts from WordPress admin takes so much time compared to deleting the posts from mySQL. Isn't WordPress doing the same thing as running few SQL commands, or there is much going on?
DELETE FROM wp_postmeta where post_id IN (SELECT ID from wp_posts where post_type = 'storelocations' );
optionally you can delete all the comments too
DELETE FROM wp_comments where comment_post_ID IN (SELECT ID from wp_posts where post_type = 'storelocations' );
and finally, you can delete all the posts
DELETE from wp_posts where post_type = 'storelocations'