[wp-trac] [WordPress Trac] #14645: Support for multiple meta_key => meta_value pairs in WP_Query

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 8 13:13:58 UTC 2010


#14645: Support for multiple meta_key => meta_value pairs in WP_Query
-------------------------+--------------------------------------------------
 Reporter:  joehoyle     |        Owner:  scribu
     Type:  enhancement  |       Status:  closed
 Priority:  normal       |    Milestone:  3.1   
Component:  Query        |      Version:        
 Severity:  normal       |   Resolution:  fixed 
 Keywords:  has-patch    |  
-------------------------+--------------------------------------------------

Comment(by scribu):

 To clarify, here's the current syntax:

 {{{
 query_posts( array(
     'meta_key' => 'foo',
     'meta_value' => 'bar',
     'meta_compare' => '>=',
     'meta_type' => 'numeric'
 ) );
 }}}

 OR

 {{{
 query_posts( array(
   'meta_query' => array(
     array(
       'key' => 'foo',
       'value' => 123,
       'compare' => '>=',
       'type' => 'numeric'
     ),
     array(
       'key' => 'foo2',
       'value' => array( 'bar2', 'bar3' )
       'compare' => 'IN',
     ),
   )
 ) );
 }}}

 The arguments are documented in WP_Object_Query::get_meta_sql()

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


More information about the wp-trac mailing list