[wp-trac] [WordPress Trac] #16579: $groupby should be set for 'meta_query' too (was: Custom fields Query)

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 17 14:26:21 UTC 2011


#16579: $groupby should be set for 'meta_query' too
---------------------------------+-----------------------------
 Reporter:  kerekesjoco          |       Owner:
     Type:  defect (bug)         |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  Query                |     Version:  3.1
 Severity:  major                |  Resolution:
 Keywords:  has-patch 3.2-early  |
---------------------------------+-----------------------------
Changes (by scribu):

 * keywords:  needs-patch needs-docs dev-feedback => has-patch 3.2-early
 * milestone:  Awaiting Review => Future Release


Old description:

> for sarch in multiple meta fields value
>
> http://codex.wordpress.org/Function_Reference/query_posts#Custom_Field_Parameters
>
> $args = array(
>         'post_type' => 'product',
>         'meta_query' =>
>                 array(
>                         'key' => 'color',
>                         'value' => 'blue',
>                         'compare' => 'NOT LIKE'
>                 ),
>                 array(
>                         'key' => 'price',
>                         'value' => array( 20, 100 ),
>                         'type' => 'numeric',
>                         'compare' => 'BETWEEN'
>                 )
> )
> query_posts( $args );
>
> corection:
> $args = array(
>         'post_type' => 'product',
>         'meta_query' => '''array('''
>                 array(
>                         'key' => 'color',
>                         'value' => 'blue',
>                         'compare' => 'NOT LIKE'
>                 ),
>                 array(
>                         'key' => 'price',
>                         'value' => array( 20, 100 ),
>                         'type' => 'numeric',
>                         'compare' => 'BETWEEN'
>                 )
>       ''' )'''
> )
> query_posts( $args );
>
> and in query.php lines
>
> if ( !empty( $this->tax_query->queries ) || !empty( $q['meta_key'] ) ) {
>                         $groupby = "{$wpdb->posts}.ID";
> }
> add:
> || !empty( $q['meta_query'] )
>
> final code:
>

> if ( !empty( $this->tax_query->queries ) || !empty( $q['meta_key'] ) ||
> !empty( $q['meta_query'] )) {
>                         $groupby = "{$wpdb->posts}.ID";
> }

New description:

 See patch.

--

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


More information about the wp-trac mailing list