metaquery having same metakey with multiple value

101 views Asked by At

I want to show the records which are having "modelyear between 2003 to 2006 and modelyear between 2007 to 2009 AND price between 1 lakh to 3 lakh and price between 3 lakh to 5 lakh" MEANS records having modelyear between 2003 to 2009 and price between 1 lakh to 5 lakh like in jabong.com narrow search.

I used the following (see below). But it's not working.

Could someone suggested, how to solve it in wordpress meta query? Please!

<?php 
$args2=array(
'posts_per_page' => 100,
'post_type' => 'product',
'post_status' => 'publish',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'year',
'value' => array(2003, 2006),
'compare' => 'BETWEEN',
//'type' => 'DECIMAL',
),
array(
'key' => 'year',
'value' => array(2007, 2009),
'compare' => 'BETWEEN',
//'type' => 'DECIMAL',
),


array(
'key' => '_price',
'value' => array(1, 3),
'compare' => 'BETWEEN',
//'type' => 'DECIMAL',
),
array(
'key' => '_price',
'value' => array(3, 5),
'compare' => 'BETWEEN',
//'type' => 'DECIMAL',
),

),
);
?>
0

There are 0 answers