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!
🚀 This week’s session of ACF Chat Fridays dips into the preliminary results of our first ever user survey. Don’t miss it! https://t.co/3UtvQbDwNm pic.twitter.com/kMwhaJTkZc— Advanced Custom Fields (@wp_acf) May 9, 2023
© 2023 Advanced Custom Fields.