In WordPress, I’m trying to run a query to return a postID where it has been tagged by two (both) ‘tags’. I think I may need a subquery of some sort. Any help appreciated, here;s what I have so far.
SELECT wposts .id
FROM wp_posts wposts
INNER JOIN wp_term_relationships ON(wposts.ID = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy ON(wp_term_relationships.term_taxonomy_id =wp_term_taxonomy.term_taxonomy_id)
INNER JOIN wp_terms ON(wp_term_taxonomy.term_id = wp_terms.term_id)
WHERE wposts.post_status = 'publish' AND wposts.post_type = 'header-image' AND wp_term_taxonomy.taxonomy = 'tags' AND ( wp_terms.name ='homepage' AND wp_terms.name ='position1' )
1 Answer