Looking for SQL query to Delete WordPress default Post or Custom Post type with their related all Post Meta from your WordPress Database. We will show you how to easily delete it from PhpMyAdmin by execute SQL simple query.
To delete all posts by a specific meta key and meta value use the following SQL query:
Dont forgot to change WordPress Database Table Prefix if you are using any Other prefix instead of WordPress default wp_
DELETE p, pm FROM wp_posts p INNER JOIN wp_postmeta pm ON pm.post_id = p.ID WHERE pm.meta_key = 'meta_key_name' AND pm.meta_value = 'meta_value';
SQL Query for Delete Custom Post Type with their related all Post Meta data
DELETE p, pm FROM wp_posts p INNER JOIN wp_postmeta pm ON pm.post_id = p.ID WHERE p.post_type= 'your_custom_post_type';