I have WP_Query that works well:
$args = array(
'post_type' => 'product',
'meta_key' => 'product_subtype',
'meta_value'=> 'public',
'compare' => '='
);
but since I want to search for several meta_keys, I tried the syntax "array":
$args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'meta_key' => 'product_subtype',
'meta_value' => 'public',
'compare' => '='
),
),
);
but it does not work - it gives me all messages with 'post_type' = 'product' - although this is the same request. I do not know why. Can someone point out a mistake?
I fulfill the request as follows (for example, this is said in all the textbooks we found)
$the_query = new WP_Query( $args );
as I said, the first way works, and I only get products with "product_subtype = public", the second ignores the array of meta-requests. But why?
source
share