Home › Forums › General Issues › Setting up front end filtering and sorting by custom fields › Reply To: Setting up front end filtering and sorting by custom fields
Hi @lewmaster
It looks liek the issue is coming from the ACF field not being found. Can you please debug the $field variable like so:
$field = get_field_object('bedrooms');
echo '<pre>';
print_r( $field );
echo '</pre>';
My guess is that ACF does not know where to find the field. The get_field_object function will only work if a value has already been saved to the current $post.
If your code is not run on single post page, then ACF will not be able to load the field. Perhaps you will need to change bedrooms
to the field_key.
using the field_key removes the need to lookup the value => key relationship.
Thanks
E
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.