[wp-trac] [WordPress Trac] #12891: Advanced multi-taxonomy WP_Query()s

WordPress Trac wp-trac at lists.automattic.com
Fri Nov 19 21:14:49 UTC 2010


#12891: Advanced multi-taxonomy WP_Query()s
----------------------------+-----------------------------------------------
 Reporter:  markjaquith     |       Owner:  markjaquith    
     Type:  task (blessed)  |      Status:  assigned       
 Priority:  normal          |   Milestone:  3.1            
Component:  Query           |     Version:  3.0.1          
 Severity:  normal          |    Keywords:  ongoing-project
----------------------------+-----------------------------------------------

Comment(by ryan):

 {{{
 WP_Query( array( 'category_name' => 'A Cat', 'showposts' => '1' ) );
 }}}

 Produces the following assortment of queries:

 {{{
 SELECT wp_trunk_term_taxonomy.term_id
 FROM wp_trunk_term_taxonomy
 INNER JOIN wp_trunk_terms USING (term_id)
 WHERE taxonomy IN ('category')
 AND wp_trunk_terms.slug IN ('a')

 SELECT wp_trunk_term_taxonomy.term_id
 FROM wp_trunk_term_taxonomy
 INNER JOIN wp_trunk_terms USING (term_id)
 WHERE taxonomy IN ('category')
 AND wp_trunk_terms.slug IN ('cat')

 SELECT t.*, tt.* FROM wp_trunk_terms AS t INNER JOIN
 wp_trunk_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy =
 'category' AND t.slug = 'a' LIMIT 1

 SELECT SQL_CALC_FOUND_ROWS wp_trunk_posts.* FROM wp_trunk_posts WHERE 1=1
 AND wp_trunk_posts.post_type IN ('post', 'page', 'attachment') AND
 (wp_trunk_posts.post_status = 'publish' OR wp_trunk_posts.post_status =
 'private') GROUP BY wp_trunk_posts.ID ORDER BY wp_trunk_posts.post_date
 DESC LIMIT 0, 1
 }}}

 The final query simply returns the latest post, regardless of category.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/12891#comment:142>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list