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.
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?
