Hi. How can we help?

How to show a different content for endpoint in according to the site language (with WPML) using YITH Customize My Account Page

YITH WooCommerce Customize My Account Page is fully compatible with WPML.
Unfortunately it's not possible "translate" the custom content you use for your endpoint, but you can use a workaround to show a different content in according to the site language.
Please add following code to the file functions.php of your theme.
 
add_shortcode( 'wpml_language', 'wpml_find_language');
function wpml_find_language( $attr, $content = null ){
extract(shortcode_atts(array(
'language' => '',
), $attr));

$current_language = ICL_LANGUAGE_CODE;

if($current_language == $language){
$output = do_shortcode($content);
}else{
$output = "";
}

return $output;
}
 
This code allow you to use a special shortcode thanks to which the endpoint content can be change dynamically in according to the language site.
Wrap the content you want show like in the example, specifing as attribute of the shortcode the ID of the associate language.
 
EXAMPLE
[wpml_language language="en"] Hi this is my text for the english site [/wpml_language]
 
[wpml_language language="it"] Hi this is my text for the italian site [/wpml_language]
 
 
Was this article helpful?
0 out of 0 found this helpful

Back to Help Center >