Answer the question
In order to leave comments, you need to log in
Is it possible to filter in wordpress via wp_query() considering all fields?
Is it possible to filter in wordpress via wp_query() considering all fields? That is, all fields must be taken into account
'meta_query' => [
'relation' => 'OR',
[
'key' => 'color',
'value' => array('red', 'blue', 'white'),
'compare' => '='
],
[
'key' => 'price',
'value' => array('20', '50', '180'),
'compare' => '='
],
[
'key' => 'age',
'value' => array('20', '30', '40'),
'compare' => '='
]
]
Answer the question
In order to leave comments, you need to log in
If "value" is an array then "compare" can only be: IN, NOT IN, BETWEEN, NOT BETWEEN.
'meta_query' => [
'relation' => 'AND',
[
'key' => 'color',
'value' => array('red', 'blue', 'white'),
'compare' => 'IN'
],
[
'key' => 'price',
'value' => array('20', '50', '180'),
'compare' => 'IN'
],
[
'key' => 'age',
'value' => array('20', '30', '40'),
'compare' => 'IN'
]
]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question