Support

Account

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>";
    	}    
    }