Nicolas Lorand
Nicolas Lorand

Reputation: 31

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 !

Upvotes: 0

Views: 283

Answers (1)

Outsource WordPress
Outsource WordPress

Reputation: 3809

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');

Upvotes: 1

Related Questions