Skip to content
Advertisement

WordPress delete posts not in specific categories using wpdb query

How do I modify the following query to delete all posts with the custom post type “listings” that are NOT IN specific WordPress categories?

Note, I must use $wpdb->query() in my particular situation. My categories for exclusion are term ID’s 21, 22, and 24.

UPDATE – THIS query brings me a lot closer to what I am after but throws a SQL error.

Error:

Advertisement

Answer

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement