Search code examples
wordpresswoocommercewpml

WPML : get link of a woocommerce category


I use this code to display a link to woocommerce categories :

echo'<a href="' . get_term_link( 38, 'product_cat' ) .'" class="discover">Click</a>';

I tried this to get the link in the current language :

apply_filters( 'wpml_element_link', 38, 'product_cat' );

But it doesn't work...

Have you got an idea ?

Thank you so much !


Solution

  • Try this and let me know whether it helps.

    $pdt_cat_id = (int)icl_object_id(38, 'product_cat', false, ICL_LANGUAGE_CODE);
    $link = get_term_link($pdt_cat_id, 'product_cat');