Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 9:00 – 15:00 - -
- - - - - - -

Supporter timezone: Asia/Yerevan (GMT+04:00)

This topic contains 0 replies, has 0 voices.

Last updated by Christopher Amirian 3 weeks, 3 days ago.

Assisted by: Christopher Amirian.

Author Posts
January 28, 2025 at 8:53 am #16640337

beverlyL

Background of the issue:
I am trying to create custom navigation links for WooCommerce product categories in the file woocommerce/archive-product.php. Here's the code I have: Coin des Girls – Bain Coin des Girls – Lingerie Coin des Girls – Prêt-à-porter . The 3 categories you see in the code are in French only (the default language). Link to a page where the issue can be seen: hidden link

Symptoms:
The get_term_link() function randomly generates links that direct users to English or German, where the category does not exist in those languages. I expected that if I'm on French, the user should be directed to the French category link. Instead, I got links randomly directing to English or German.

Questions:
Why does get_term_link() generate links to non-existent categories in English or German?
How can I ensure that users are directed to the correct French category link?

January 28, 2025 at 9:00 am #16640393

Christopher Amirian
Supporter

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

Would you please follow the steps mentioned din the chat and get back to us with the result?

Use the "wpml_object_id" to get the ID of the translated category and then use it in your code.
For more information:

https://wpml.org/wpml-hook/wpml_object_id/
Here was a similar thing with another customer:

https://wpml.org/forums/topic/when-i-use-get_term_linkterm-i-dont-get-the-translated-woocommerce-product-ca/

The topic ‘[Closed] problem with get_term_link() for WooCommerce product category’ is closed to new replies.