Home › Forums › General Issues › get_fields stops working when taxonomy term used in custom post type › Reply To: get_fields stops working when taxonomy term used in custom post type
Can you explain more what you mean by this statement?
“7) I then added a ‘course_categories’ selection to the ‘courses’ I had created.”
What do you mean by ‘selection’? Radio buttons? A Select drop-down?
Just off the top of my head, if you are adding a taxonomy to your custom post type, you don’t need to add an additional ACF selection field, especially with the same slug/name. This will create unexpected results.
Once you’ve created the custom taxonomy, you can use the built-in WordPress support for taxonomies.
In any case, you have two options so pick one but you shouldn’t really use both:
1) If you want to use your custom taxonomy, make sure your cpt supports the custom taxonomy and vice-versa that your custom taxonomy is attached to your custom post type.
Then, make sure your edit screen for your custom post type has your taxonomy box checked in ‘Screen Options’. It should look just like the category box for regular Posts.
Select your taxonomies for your custom post type posts using that box (no ACF select field necessary).
— OR —
2) Use an ACF select field (either Select or Checkbox) and then you can query posts by that field (scroll down to Examples): https://www.advancedcustomfields.com/resources/query-posts-custom-fields/
Thus, you should either use your custom taxonomy or an ACF field but not both – you are just re-selecting something that is already there.
All that said, there could be uses for grabbing your taxonomies in ACF but make sure that your ACF fields do not have the same slugs as your custom taxonomy.
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!
ACF wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.