bartU-2
Hi,
I have a theme, with different option fields, in which I can input text.
I need one field, to be able to contain two languages at the same time:
[wpml_language language=”en”]Free shipping [/wpml_language]
[wpml_language language=”nl”]Gratis verzending[/wpml_language]
I find it confusing, that we have to look in the gigantic haystack, to hope to find that one string and translate it.
It would be more user-friendly, just to add the languages in one field if I choose to.
With qTranslate such efficiënt conditional languages shortcodes are possible.
I tried this plugin, but it does not work :
https://wordpress.org/plugins/wpml-short-code-translator/
Noman
Supporter
Languages:
English (English )
Timezone:
Asia/Karachi (GMT+05:00)
Hi,
Thank you for contacting WPML Support.
- You can achieve it using built in WPML shortcode and WPML String Translation plugin:
[wpml-string context="my-domain" name="my-name"]My string[/wpml-string]
Here is doc for more details:
https://wpml.org/documentation/support/wpml-coding-api/shortcodes/#wpml-string
OR
- You can achieve it using custom shortcode as follows:
1. Please add this function in your theme’s or child theme functions.php file
add_shortcode( 'wpml_language', 'wpml_language_func');
function wpml_language_func( $attr, $content = null ){
extract(shortcode_atts(array(
'language' => '',
), $attr));
$current_language = ICL_LANGUAGE_CODE;
if($current_language == $language){
$output = do_shortcode($content);
}
return $output;
}
2. Then use below shortcodes in your post/pages where you want:
[wpml_language language="en"]Free shipping [/wpml_language]
[wpml_language language="nl"]Gratis verzending[/wpml_language]
I hope it helps,
Thank you
bartU-2
Works like a charm Norman, you genius !
Thanks man 🙂