Home › Forums › General Issues › Querying a relationship field with a custom field filter › Reply To: Querying a relationship field with a custom field filter
In that case, you need extra parameters to query the doctors like this:
$doctors = get_posts(array( 'post_type' => 'doctor', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'location', // name of custom field 'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234" 'compare' => 'LIKE' ), array( 'key' => 'gender', 'value' => 'male', 'compare' => 'LIKE' ) ) ));
If you want the radio button to act like a filter, please take a look at this page to learn more about filtering posts with ACF: https://www.advancedcustomfields.com/resources/creating-wp-archive-custom-field-filter/
I hope this helps 🙂
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've just released ACF 5.12.3 with a security fix to prevent arbitrary file uploads to forms with ACF fields.— Advanced Custom Fields (@wp_acf) July 14, 2022
Now that we've released this update, we recommend updating your sites as soon as possible.
© 2022 Advanced Custom Fields.