Home › Forums › Front-end Issues › Custom taxonomy slug not ID (again, i know) › Reply To: Custom taxonomy slug not ID (again, i know)
Wow!
Thanks for the super quick reply!
Unfortunately it didn’t do the magic.
Actually, pretty weird, your code (with the right field name “tecnica”) doesn’t output anything at all!
My code is:
<?php if( get_field('tecnica') ): ?>
<?php $field_name = "text_field"; $field = get_field_object(tecnica); echo $field['label']; ?>:<?php the_field('tecnica'); ?>
<?php endif; ?>
(i need the label too, for possible future translations)
I’ve set it to use radio button, because i need just one category (the tecnique used for a painting,it’s for a painter catalogue).
I’ve tried to set as an html select, or a multiple category,and i get the array, but always with the id.
The code you suggested with the correct field ‘tecnica’ is
$terms = get_field('tecnica');
// if you are expecting a single value
if (is_array($terms)) {
$term = $terms[0];
}
echo $term->name;
// if you are expecting an array
if (!is_array($terms)) {
$terms = array($terms);
}
foreach ($terms as $term) {
echo $term->name;
}
I’m working on Xaamp on my old laptop, PHP Version is 5.6.14…
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.