I am working on a piece of code used to create a woocommerce product in 2 languages and I have managed to do that with the product itself although I am having a problem with the categories for the 2 languages.
$all_cats = get_terms(array(
'taxonomy' => 'product_cat',
'hide_empty' => false,
'name' => trim($category),
));
using
$sitepress->switch_lang($alt_lang, true);
to switch language and then doing the same query both return the same term_id.
Printing $sitepress->get_current_language()
before each query shows the correct language being chosen.
![enter image description here](https://i.stack.imgur.com/w4Ozn.png)
I have also tried both of the first 2 options in case it defaults to one language, I have tried using apply_filters('wpml_object_id',...);
and icl_object_id
to no avail.
How would I force wordpress to provide me with the categories of the current language only and if there aren't return nothing?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…