Home › Forums › Add-ons › Gallery Field › Empty array when ordering posts by meta_value › Reply To: Empty array when ordering posts by meta_value
The issue for me was specific to $query->set('s', ' ');
. I added it to fix empty search queries returning a 404 page.
I set a bunch of other query vars in the same function but going through one by one, this was the only one to cause error.
Btw, you’re missing a single quote before date_published.
function property_filters($query) {
// ...
/**
* Fixes issue with blank search queries returning 404
*/
if (!is_admin() && isset($query->query_vars['s']) && empty($query->query_vars['s'])) {
$query->set('s', ' ');
}
}
add_action('pre_get_posts', 'property_filters');
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.