Home › Forums › General Issues › Display value for taxonomy in template › Reply To: Display value for taxonomy in template
#2
When you edit the taxonomy field, you can set the return type setting from ID to Object. The Object will return all the term data from the DB, not just the ID! Please note, you need to use the get_field function to load the value.
#1
Create a field group for the term fields (“Required Equipment” and the other “Optional Equipment”) and use the location rules to map this field group to the taxonomy term under ‘Other’.
Now, when you edit the term, you can save this extra data.
Now, back to your template. You should be on a single.php or something similar to display the $post. You can load the term like so:
$term = get_field('equipment');
Then you can load the equiptment data like so:
$required_equipment = get_field('required_equipment', $term);
Notice that you can pass the $term object through to the function to tell ACF to load from that object, not from the global $post object.
Hope that helps.
Please note that to pass in a $term object, you will need to be using a recent version of ACF (4.3.3)
Thanks
E
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!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz
— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.
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.