Home › Forums › Backend Issues (wp-admin) › Changing query of Post Object field upon changing the field › Reply To: Changing query of Post Object field upon changing the field
First you would need to add custom JavaScript. The basics are covered here https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/
Using the new JS API for ACF you would create a filter using this hook https://www.advancedcustomfields.com/resources/javascript-api/#filters-select2_args. In this filter you would get the values of the other relationship field and add them to the ajax data being sent. You would do this using the field functions https://www.advancedcustomfields.com/resources/javascript-api/#acf.field.
Finally you would create the acf/fields/post_object/query filter that would use the information to filter the posts using the new data that is sent, more than likely by adding a post__not_in
argument.
Sorry I can’t be more specific or give you example code, but I don’t have more at the moment.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.