‘value’ can be an array if you change ‘compare’ to ‘IN’.
Hi, thanks for reply.
That’s what I’ve end up with so far. But it is not kind of the same, because when u use LIKE, it searsech %value% with wildcards. When you have IN, it searches exact VALUE. And even if I send %value% to IN comparison, it does not work.
Since I can’t see your entire args, you will need to modify the code below. You can use multiple entries in a meta_query with an ‘OR’ relation:
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'the key',
'value' => '543',
'compare' => 'LIKE'
),
array(
'key' => 'the key',
'value' => 'London',
'compare' => 'LIKE'
)
array(
'key' => 'the key',
'value' => 'foo',
'compare' => 'LIKE'
)
)
);
Hi, thanks.
That’s my fault, I should have pst the args in the first post. Thing is, I have args like this
$args = array(
'post_type' => 'product',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'number',
'value' => array(1, 1000),
'compare' => 'BETWEEN'
),
array(
'key' => 'county',
'value' => array('OC','CO'),
'compare' => 'IN'
),
...,
array(
// AND there I need what I asked for, so something like.
'relation' => 'OR',
array(...LIKE...),
array(...LIKE...),
array(...LIKE...)
)
)
);
Args in the begining are from inputs like dropdown, multiselect, radio and numeric inputs (so the inputs are exact), but the last part of query is “fulltext” input of words divided with “,” and I wanted to assure, that I eliminate some of human mistakes during input of text strings (so I wanted to use wildcards = LIKE comparison).
Maybe I am approaching it from completely wrong way, so If somebody knows prettier, better or working way, you are welcome to throw me some hint 🙂
I don’t think you will be able to do this with query_posts args. I believe that you will need to build up the sql for the query or use a filter to add to the query.
that is what was affraid of 😀