I created some posts using a custom post type, then I decided to delete this custom post type but of course the old posts remained orphan inside the database.

How can I remove these orphan posts and all related attachment (post meta, etc.) safely from DB?

2 Answers
2

DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID=b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID=c.post_id)
WHERE a.post_type="customposttype"

Leave a Reply

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