Home › Forums › General Issues › Issue displaying taxonomies names and links: not a string? › Reply To: Issue displaying taxonomies names and links: not a string?
For anyone who needs it, my error was that I had to use
get_term_link(term-slug, taxonomy-slug)
with the term slug and the taxonomy slug, while I was using the ID and did not use the taxonomy slug.
So the final code I used is:
$terms = get_field('acf_tax_fieldname');
if( $terms ) {
foreach( $terms as $term ) {
$term_name = get_term( $term )->name;
$term_slug = get_term( $term )->slug;
$term_link = get_term_link( $term_slug , 'wp_tax_slug' );
echo "<a href='" . $term_link . "'>" . $term_name . "</a>";
}
}
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.