Home › Forums › Backend Issues (wp-admin) › Custom Taxonomies in Taxonomy Select Menu not showing results
I have added a group of taxonomy types to my News posts that gather Towns as a taxonomy. Towns is a custom Taxonomy created through CPT-Onomies. I have noticed that selecting a Town from the taxonomy select menu will properly save the field, but will not show the actual results after reloading the admin page in the select menu. Other notes from testing:
– The town originally saved is still highlighted when I click the down arrow of the select menu
– I also tested this with a custom taxonomy created through Custom Post Types UI as well as the generic taxonomy. Both worked as you would expect (showing the result in the select menu after reloading the admin post page).
– For my case, there should only be one town, so I also tried showing the town tags as a Taxonomy Radio Button field. That worked as you would expect.
– I have tried changing the return value from Term Object to Term ID, but that shows the same issue.
I have attached 3 screenshots to show what the select menu:
acf_taxonomy_before — what the select menu looks like after I have selected a town but before saving my result.
acf_taxonomy_after — what the select menu looks like after I have saved the post and reload the admin post page. Please note that the town selected is highlighted in the dropdown, but is not showing at the top (in the actual select menu portion.
acf_taxonomy_after_collapsed — This is the same as acf_taxonomy_after, but the select menu is not open to see the selection list. Please note that the selection is not shown at all to the user, so it looks like nothing was ever selected.
It seems that CPT-onomies use a post as the custom taxonomies. ACF saves the taxonomy id in the database and assumes that it is indeed a taxonomy. When it renders the field, it tries to find a normal taxonomy with that id and, of course, can’t find it. Please Use CPT UI instead.
I hope this makes sense.
Thanks for your reply, James. The part I am still confused about is if ACF is not able to find the Taxonomy because CPT-onomies is using a postID instead of a Taxonomy ID (so ACF is not able to find the taxonomy to display it), why is ACF able to highlight the correctly set taxonomy in the select menu dropdown options? I would have thought that if ACF is able to get the select taxonomy to highlighting the correct option, it should have enough data to also populate the select menu (before the options are displayed).
My original post has an image named “acf_taxonomySelect_after.png” that shows this exact scenario. The town originally selected was “Bourne”. After saving the post, the select menu is blank, but opening it to see the options shows that Bourne is properly highlighted.
I believe it’s because the field uses wp_get_object_terms() to get the taxonomies for the field and uses get_terms() to get the taxonomy list. You can take a look at the plugin core file here “wp-content/plugins/advanced-custom-fields-pro/fields/taxonomy.php”.
I’m not sure how CPT-onomies works, but maybe you can’t get the taxonomy using wp_get_object_terms()? Please ask the plugin author about this issue.
You must be logged in to reply to this topic.
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!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.— Advanced Custom Fields (@wp_acf) February 23, 2023
© 2023 Advanced Custom Fields.