As noted in the documentation meta_value
, when not used inside a meta query, needs to be a string.
Normally if you want to query based on multiple meta values you need to add a meta_query
argument. But also as noted in the documentation regarding value
:
It can be an array only when
compare
is'IN'
,'NOT IN'
,
'BETWEEN'
, or'NOT BETWEEN'
.
Since NOT LIKE
isn’t one of these, this means you would need to add multiple NOT LIKE
meta queries with an AND
relation, like so:
$query = new WP_Query( array(
'post_type' => 'estate',
'post_status' => 'any',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'getrix_id',
'value' => 'miogest_',
'compare' => 'NOT LIKE',
),
array(
'key' => 'getrix_id',
'value' => 'oneclick_',
'compare' => 'NOT LIKE',
),
array(
'key' => 'getrix_id',
'value' => 'gestifiaip_',
'compare' => 'NOT LIKE',
),
),
) );
However this is pretty verbose. A simpler way would be to use NOT REGEXP
as the comparison. This will let you pass a regular expression that would return true for any values beginning with miogest_
, oneclick_
, or gestifiaip_
, and then only return results for which that doesn’t return true:
$query = new WP_Query( array(
'post_type' => 'estate',
'post_status' => 'any',
'meta_key' => 'getrix_id'
'meta_compare' => 'NOT REGEXP',
'meta_value' => '^(miogest_|oneclick_|gestifiaip_)',
) );