Products Query (TAX + META)
// WP_Query arguments
$args = array(
'post_type' => array( 'product', ' product_variation' ),
'paged' => '1',
'posts_per_page' => '10',
'order' => 'ASC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_cat',
'terms' => '16',
'field' => 'term_id',
'operator' => 'IN',
),
),
'meta_query' => array(
array(
'key' => 'bs_id',
'value' => '[7,13]',
'compare' => 'BETWEEN',
'type' => 'DECIMAL',
),
array(
'key' => 'bs_cs',
'value' => '[0,6]',
'compare' => 'BETWEEN',
'type' => 'DECIMAL',
),
),
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// do something
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();