I am writing an import application and I would like to check if a specific term exists in a specific language. If it does not then create the term in that language.
questions:
- How to make sure get_term_by() searches inside the EN terms?
- How to make sure wp_insert_term() saves as an EN term?
// Switch to EN
global $sitepress;
$language_code = "en";
$original_lang = ICL_LANGUAGE_CODE;
$sitepress->switch_lang($language_code);
$term_name = 'sample';
// How to make sure it searches inside the EN terms?
$term = get_term_by('name', $term_name, 'product_cat');
if (! $term) {
// How to make sure it is saved as an EN term?
$result = wp_insert_term($term_name, 'product_cat');
}
// Switch back to original language
$sitepress->switch_lang($original_lang);
They are trying reproduce the issue and checking this.
Sorry for the delay.
I will update you again once they find something (that will happen within this week)
Our developers informed me that your code work as expected.
Could you please explain what is the exact issue you are having with this? perhaps, adding some screenshots also will help in this.