Home › Forums › Backend Issues (wp-admin) › Dynamically populate relationship field › Reply To: Dynamically populate relationship field
You cannot modify the choices of a relationship field by using a load field filter. These can really only be modified by using the method you mentioned https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/
On a taxonomy page, or any page, ACF sends the current post ID as part of the request. I just did a test and here is what is in the $_POST array for the request.
Array
(
[paged] => 1
[taxonomy] =>
[post_type] =>
[s] =>
[max] =>
[min] =>
[action] => acf/fields/relationship/query
[field_key] => field_587ba38bc815c
[post_id] => category_4
[nonce] => b12e5fd166
)
In your acf/fields/relationship/query filter you can look at the post_id
value. From this you can get the taxonomy and the term ID. You can then use these values to modify the query args you return from your filter so that only posts in the current term are returned.
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.