Hi,
At first thanks for your suitable plugin. I got a problem. I have used ACF fields with 2 checkbox, 2 radio and 1 text. It’s working well. My problem is I need to create a faceted search with those 5 fields. I have followed a code of your forum. But I can’t create relation with this 5 fields. I need to 5 fields search together or individually. I have used if else but I think its not proper way. How can I create an argument by 5 fields for faceted search?
if(empty($bedroom OR $bathroom)){
$args = array(
‘numberposts’ => -1,
‘post_type’ => ‘apartment’,
‘meta_query’ => array(
‘relation’ => ‘AND’,
array(
‘key’ => ‘apartment_price’,
‘value’ => array($minp,$maxp),
‘compare’ => ‘BETWEEN’,
‘type’ => ‘NUMERIC’,
),
)
);
//var_dump($args);
}
elseif (!empty($bedroom OR $bathroom)) {
$args = array(
‘numberposts’ => -1,
‘post_type’ => ‘apartment’,
‘meta_query’ => array(
‘relation’ => ‘AND’,
array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘bedroom’,
‘value’ => $bedroom,
‘compare’ => ‘=’
),
array(
‘key’ => ‘bathrooms’,
‘value’ => $bathroom,
)
),
array(
‘key’ => ‘apartment_price’,
‘value’ => array($minp,$maxp),
‘compare’ => ‘BETWEEN’,
‘type’ => ‘NUMERIC’,
),
)
);
}
if(isset($_GET[‘ap_features’])) {
$meta_query = array(‘relation’ => ‘OR’);
foreach ($_GET[‘ap_features’] as $value) {
$meta_query[] = array(
‘key’ => ‘apartment_features’,
‘value’ => ‘”‘.$value.'”‘,
‘compare’ => ‘LIKE’
);
}
$args = array(
‘numberposts’ => -1,
‘post_type’ => ‘apartment’,
‘meta_query’ => $meta_query
);
}else{
//echo ‘<h1>Not ap_features Selectetd</h1>’;
}
if(isset($_GET[‘community’])) {
$meta_query = array(‘relation’ => ‘OR’);
foreach ($_GET[‘community’] as $value) {
$meta_query[] = array(
‘key’ => ‘co_fetu’,
‘value’ => ‘”‘.$value.'”‘,
‘compare’ => ‘LIKE’
);
}
$args = array(
‘numberposts’ => -1,
‘post_type’ => ‘apartment’,
‘meta_query’ => $meta_query
);
}else{
//echo ‘<h1>Not community Selectetd</h1>’;
}