get_term_link() returns incorrect url

I have a custom post type (item) with multiple custom taxonomies (item_category_A, item_category_B, etc.) I’d like to retrieve custom taxonomy terms of the current item from item_category_A, also make them clickable. My code retrieves the correct terms, but then using get_term_link() retrieves a url, looking like . What am I doing wrong? My code looks like this:

function get_item_category_A(){

   $item_cat_A = get_the_terms(get_the_ID,'item_category_A');

   echo '<a href="' . esc_url(get_term_link($item_cat_A[0]->slug,$item_cat_A[0]->taxonomy)).'">'.esc_html($item_cat_A[0]->name).'</a>';


Still, when I run the function, it returns the url than points to the correct term in the incorrect taxonomy (

Read more here: get_term_link() returns incorrect url

Leave a Reply

Your email address will not be published. Required fields are marked *