[wp-trac] [WordPress Trac] #9268: WP_Query->query() fails when both 'cat' and 'tag' parameters are specified

WordPress Trac wp-trac at lists.automattic.com
Tue Mar 3 17:47:27 GMT 2009


#9268: WP_Query->query() fails when both 'cat' and 'tag' parameters are specified
--------------------------+-------------------------------------------------
 Reporter:  Nick Higgs    |       Owner:  anonymous 
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  General       |     Version:            
 Severity:  normal        |    Keywords:            
--------------------------+-------------------------------------------------
 WP_Query->query() will always return no posts if both the 'cat' and 'tag'
 parameters are specified.

 Examing the query generated, it appears that this is because the term
 related tables are only joined once, rather than twice for both categories
 and tags. e.g.

 SELECT   wp_posts.*
 FROM wp_posts
 INNER JOIN wp_term_relationships ON (wp_posts.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 1=1
 AND wp_term_taxonomy.taxonomy = 'category'
 AND wp_term_taxonomy.term_id IN ('15')
 AND wp_term_taxonomy.taxonomy = 'post_tag'
 AND wp_terms.slug IN ('my-tag-slug')
 AND wp_posts.post_type = 'post'
 AND (wp_posts.post_status = 'publish')
 GROUP BY wp_posts.ID
 ORDER BY wp_posts.post_date DESC

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9268>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list