So far good, add taxonomy condition by checking the suburbs
and states
Value.
// Suburbs
if( !empty( $_GET['suburbs'] ) ) {
$suburbs = $_GET['suburbs'];
}
// States
if( !empty( $_GET['states'] ) ) {
$states = $_GET['states'];
}
// Query arguments.
$args = array(
'post_type' => 'properties',
'posts_per_page' => 10,
);
$taxquery = array();
// if $state variable is selected.
if(!empty($states) || isset($suburbs) ){
array_push($taxquery,array(
'taxonomy' => 'state',
'field' => 'slug',
'terms' => $states,
));
}
// if $suburbs variable is selected.
if(!empty($suburbs) || isset($suburbs) ) ){
array_push($taxquery,array(
'taxonomy' => 'suburb',
'field' => 'slug',
'terms' => $suburbs,
));
}
// if $taxquery has array;
if(!empty($taxquery)){
$args['tax_query'] = $taxquery;
}
// And finally fetch the all post.
$property_query = new WP_Query($args);
Replace your PHP code with this. It will definitely solve your problem đ