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
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.
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!
© 2022 Advanced Custom Fields.