Home › Forums › General Issues › Querying a relationship field with a custom field filter › Reply To: Querying a relationship field with a custom field filter
Hi @charlesr
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 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.