Created
October 4, 2011 13:36
-
-
Save timbroder/1261659 to your computer and use it in GitHub Desktop.
delete wordpress posts by category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT p.post_title, p.ID, wpr.object_id, wp_terms.term_id, wp_terms.name, wp_term_taxonomy.taxonomy | |
FROM wp_terms | |
INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id | |
INNER JOIN wp_term_relationships wpr ON wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id | |
INNER JOIN wp_posts p ON p.ID = wpr.object_id | |
WHERE taxonomy = 'category' | |
AND p.post_type = 'post' | |
AND p.post_status = 'publish' | |
AND name != 'Code' | |
ORDER BY object_id; | |
DELETE | |
FROM p using wp_terms | |
INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id | |
INNER JOIN wp_term_relationships wpr ON wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id | |
INNER JOIN wp_posts p ON p.ID = wpr.object_id | |
WHERE taxonomy = 'category' | |
AND p.post_type = 'post' | |
AND p.post_status = 'publish' | |
AND name = 'Meals'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment