Home › Forums › General Issues › Dynamically Filter Post Object Dropdown? › Reply To: Dynamically Filter Post Object Dropdown?
There isn’t a way that I know of to filter a post object field based on a selection in another field or fields, at least not built into ACF. A post object field is a select2 field and the contents of this field are generated by an AJAX request. Information from other fields is not sent in that AJAX request. There might be a way to alter the alter the request, but nothing that I can remember has ever been posted here about how to do it and I have not been able to figure that out. If you can figure out how to alter this AJAX request then you could use https://www.advancedcustomfields.com/resources/acf-fields-post_object-query/ to get the additional information from the request ($_POST) and alter the query.
More than likely, if I needed to do this in a hurry I would use a basic select field rather than a post object field and I’d build custom JavaScript and a custom AJAX function to allow me to filter the list shown in this field. I have an example of this here https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example
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.