[wp-trac] [WordPress Trac] #16579: Custom fields Query
WordPress Trac
wp-trac at lists.automattic.com
Thu Feb 17 12:38:51 UTC 2011
#16579: Custom fields Query
-------------------------+-------------------------------------------------
Reporter: kerekesjoco | Owner:
Type: defect | Status: new
(bug) | Milestone: Awaiting Review
Priority: normal | Version: 3.1
Component: Query | Keywords: needs-patch needs-docs dev-feedback
Severity: major |
-------------------------+-------------------------------------------------
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";
}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16579>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list