wordpress value compare between two meta keys
-
I have property plugin with two fields in the backend from Area and To Area.
In the front end search also I have included two search fields min area and max So if either the min area or max area falls in range of property from area or to area then it should show up result..Eg one of the properties has area between 1000-3000 as from area and to area and anyone in the front end searches either 500-2000 or 1500 -6000 shld show a result ,since in the first case 2000 falls in 1000-3000 range and in second case 1500 falls in 1000-3000 range.
I dont know whats the exact way to write a meta query comparing a value between two keys with an OR condition this is what I have achived, I get some results using <= or >= but dont know how to use between if possible please please write the code.
`$meta_query = array(
‘relation’ => ‘OR’,
array(‘key’ => array(‘property_frmarea’,’property_toarea’) (these are the 2 backend fields)
‘value’ => $_POST[‘from_size’], (this is front end from field)
‘type’ => ‘numeric’,
‘compare’ => ‘Between’
),
array(
‘key’ => array(‘property_frmarea’,’property_toarea’)
‘value’ => $_POST[‘to_size’],
‘type’ => ‘numeric’,
‘compare’ => ‘Between’
),
);
The topic ‘wordpress value compare between two meta keys’ is closed to new replies.