Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

it is possible to use a array by the this query?


This Version doesnt work:

$args = array( 'order' => 'ASC',
'meta_key => array('city_1','city_2),
'meta_value' => array('NY','LA')

);

query_posts($args);
--------------


And this Version works:


$args = array(
'order' => 'ASC',
'meta_key => 'city_1',
'meta_value' => 'LA'

);

query_posts($args);
--------------

have somebody a idea?
Thanks

share|improve this question
add comment

1 Answer

Refer to multiple custom field handling in WP_Query:

$args = array(
    'meta_query' => array(
        'relation' => 'OR',
        array(
            'key' => 'city_1',
            'value' => array('NY','LA'),
            'compare' => 'IN'
        ),
        array(
            'key' => 'city_2',
            'value' => array('NY','LA'),
            'compare' => 'IN'
        )
    )
);
query_posts($args);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.