WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 20 months ago

#16579 closed defect (bug)

Custom fields Query — at Initial Version

Reported by: kerekesjoco Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Query Keywords: has-patch reporter-feedback
Focuses: Cc:

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( $qmeta_key? ) ) {

$groupby = "{$wpdb->posts}.ID";

}
add:

!empty( $qmeta_query? )

final code:

if ( !empty( $this->tax_query->queries )
!empty( $qmeta_key? ) !empty( $qmeta_query? )) {

$groupby = "{$wpdb->posts}.ID";

}

Change History (1)

kerekesjoco3 years ago

Note: See TracTickets for help on using tickets.