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.
Regards,
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.