[Resolved] Running custom php depending on the language selected
This thread is resolved. Here is a description of the problem and solution.
Problem:
How to code PHP as per current language?
Solution:
You have to use "ICL_LANGUAGE_CODE" to get your current language.
Here is the sample code/structure
function my_custom_function() {
if(ICL_LANGUAGE_CODE=='en'){
<!--- your code to english--->
} elseif(ICL_LANGUAGE_CODE=='de'){
<!---your code to german--->
} elseif(ICL_LANGUAGE_CODE=='fr'){
<!---your code to french---
Global site tag (gtag.js) - Google Analytics -->
} elseif(ICL_LANGUAGE_CODE=='es'){
<!---your code to spanish--->
}
}
Modify your code according to this and you will get what you want.
67% of people find this useful.
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.
I am customizing the "my account" page in Woocommerce
I use my own php code to add bookmarks to the "my account" menu. The content of the added bookmarks is displayed using shortcode to custom html blocks.
Wmpl doesn't explain these bookmarks and some content from custom html blocks to me. I tried various settings including scanning while rendering pages.
I thought that I could make custom php separate for each language, thus creating dedicated content for individual languages, and that's why I need help.
How to modify php code to make it active only for a given language?
You have to use "ICL_LANGUAGE_CODE" to get your current language.
Here is the sample code/structure
function my_custom_function() {
if(ICL_LANGUAGE_CODE=='en'){
<!--- your code to english--->
} elseif(ICL_LANGUAGE_CODE=='de'){
<!---your code to german--->
} elseif(ICL_LANGUAGE_CODE=='fr'){
<!---your code to french---
Global site tag (gtag.js) - Google Analytics -->
} elseif(ICL_LANGUAGE_CODE=='es'){
<!---your code to spanish--->
}
}
Modify your code according to this and you will get what you want.