sql select posts matching multiple categories
-
Hi,
I’m trying to figure the sql to select posts matching more than 1 category (ie. the post must match every category listed).
Here’s the SQL to select one category but I can’t figure out how to make it match multiple categories.
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 (wp_terms.slug = 'surface-level') ORDER BY object_id
thanks, Trevor
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘sql select posts matching multiple categories’ is closed to new replies.