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.
This topic contains 4 replies, has 2 voices.
Last updated by aristeidisS 4 years, 6 months ago.
Assisted by: Raja Mohammed.
Author | Posts |
---|---|
June 1, 2020 at 9:03 am #6264203 | |
aristeidisS |
Tell us what you are trying to do? Looking at the product in english, the slug for the term would be something like 'bags' or 'fabric' etc. When I am looking at the product in a different language, the term is of course translated and is not 'bags' but something like 'sacs' (fr) or 'τσάντες' (el). Is there a way to correlate all the terms that are semantically the same? In other words, If I have the term 'bags' in english, how can I get all other terms that are its translations? Is there any documentation that you are following? Is there a similar example that we can see? What is the link to your site? |
June 1, 2020 at 11:56 am #6265075 | |
aristeidisS |
I can get the base language product ID by passing 'en' to this: Then, calling: gets me the terms from english product and I can then check their slugs for what I need. ISSUE: |
June 1, 2020 at 12:56 pm #6265539 | |
aristeidisS |
If the option: is ON, is there a way to make get_the_terms(ID) to return the terms for the supplied object ID and not for the one that corresponds to the currently selected language? |
June 2, 2020 at 10:02 am #6272817 | |
Raja Mohammed Supporter
Languages: English (English ) Timezone: Asia/Kolkata (GMT+05:30) |
Hello there, I am quite not clear whether you want to display all possible translation of the selected taxonomy or just want to display the taxonomy terms based on the language and post id. Adjust IDs will affect the flow and it will always force the results based on the current langauge of the page. However, you can try to switch the langauge on the fly. So your code would be something like global $sitepress; $current_lang = apply_filters( 'wpml_current_language', NULL ); // Switch the language to English before the get_terms $sitepress->switch_lang( 'en' ); $org_id = apply_filters( 'wpml_object_id', $product->get_id(), 'product', false, 'en'); $terms = get_the_terms($org_id, 'product_cat'); // Check if the terms are expected and then switch back the language $sitepress->switch_lang($current_lang); Let me know if that helps Kind regards |
June 3, 2020 at 7:48 am #6280457 | |
aristeidisS |
OK. Thanks for pointing me to the $sitepress object. |