I've written a function to get products by price range. All works, but now I need add a extra meta key, that will be like 50 - 100 and featured, but code is not returning any products. What is wrong on this code?
function product_price_filter_box($attr) {
$limit = intval($attr['limit']);
$min = intval($attr['min']);
$max = intval($attr['max']);
$query = array(
'post_status' => 'publish',
'post_type' => 'product',
'posts_per_page' => $limit,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_price',
'value' => array($min, $max),
'compare' => 'BETWEEN',
'type' => 'NUMERIC'
),
array(
'key' => 'featured',
'value' => '1',
'compare' => '=',
),
)
);
$wpquery = new WP_Query($query);
while ( $wpquery->have_posts() ) : $wpquery->the_post(); global $product;
wc_get_template_part( 'content', 'product' );
endwhile;
wp_reset_query();
}
add_shortcode( 'product_price_filter_box', 'product_price_filter_box' );