I’m trying to get a taxonomy field populated from the result of a selection in another field.
I’ve use https://github.com/Hube2/acf-dynamic-ajax-select-example/tree/master/dynamic-select-example as a template and got most of it to work – but I can’t figure out how to append the info to the taxonomy field. It’s a select2 combobox and I can figure out how to it.
This is my .js
That is a very old example and what you are seeing is why I used select fields instead of ACF Post Object, Relationship or Taxonomy fields in that example. The only reason I created that repo was to post examples from work that I’ve actually done for clients.
Since I built that ACF has added the select2_ajax_data filter hook to the JS API. This filter can be used to get the value selected in another field and pass it to the server in ACF’s AJAX request used to populate the fields I mentioned above. You can then get that value from $_POST in one of the ACF server side query filters (acf/fields/relationship/query, acf/fields/post_object/query, acf/fields/taxonomy/query, acf/fields/taxonomy/wp_list_categories) to modify what is shown by ACF.
Unfortunately, I don’t have any examples of this because I have not found a reason to build them and would not rebuild old code unless it stops working.