Any help on why this multiple meta query is not working is greatly appreciated, both meta_query
arguments have been tested independently.
I'm looking for bringing Featured products as well as Best Selling(popular) products. Currently this snippet of code is bringing all posts that are 'post_type' => 'product'
, completely ignoring the 'meta_query'
.
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => 10,
'meta_query' => array(
'relation' => 'OR',
array(
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num'
),
array(
'meta_key' => '_featured',
'meta_value' => 'yes'
)
)
);
Anybody out there in the wild?
'meta_key' => '_featured'
it shows Product 3, which is a featured product and if I query for'meta_key' => 'total_sales'
it shows Product 4, which is the best selling product. When I use the code above, it shows the last Product added, which is not featured neither best selling. Assuming that I'm querying for'posts_per_page' => 1