Home › Forums › Front-end Issues › Menu Missing With Custom Filter › Reply To: Menu Missing With Custom Filter
Nevermind I found my solution here
I just need to wrap the function with if $query->is_main_query()
statement.
if ($query->is_main_query()){
// get original meta query
$meta_query = $query -> get('meta_query');
// allow the url to alter the query
// eg. ?district=1
// eg. ?district=2
if (isset($_GET['district']) ){
$district = $_GET['district'];
$range = explode(' - ', str_replace('$', '', $_GET['price-range']));
//add meta query to the original meta queries
$meta_query[] = array(
'relation' => 'AND',
array(
'key' => 'district',
'value' => $district,
'compare' => 'IN',
),
array(
'key' => 'price',
'value' => $range[0],
'type' => 'NUMERIC',
'compare' => '>'
),
array(
'key' => 'price',
'value' => $range[1],
'type' => 'NUMERIC',
'compare' => '<'
)
);
}
// update the meta query args
$query -> set('meta_query', $meta_query);
//always return
return;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.