-
AuthorPosts
-
October 10, 2014 at 2:51 pm #333857
Hello,
Previously when I thought I would use WPML for my language versions I got this code example to use in the header element. Unfortunately WPML did not work out for me so now I am using CML (Ceceppa multilingua). And so I was wondering how to change this function to work with CML?function ava_extra_header_element() {
$banner = “<div class=’my-custom-content’>Here goes my text for the standard language!</div>”;
if(defined(‘ICL_SITEPRESS_VERSION’) && defined(‘ICL_LANGUAGE_CODE’)){
if(ICL_LANGUAGE_CODE == “de”) $banner = “<div class=’my-custom-content’>Here goes my text for the German language!</div>”;
if(ICL_LANGUAGE_CODE == “en”) $banner = “<div class=’my-custom-content’>Here goes my text for the Spanish language!</div>”;
}
}
add_action(‘ava_main_header’, ‘ava_extra_header_element’);I would appreciate any help you can offer. From CML I got this suggestion, but it doesn’t work:
cml_shortcode_text( array(
‘fi’ => ‘<div class=’slogan’>
<p class=”slogan_main”>Puhallus</p>
<p class=”slogan_sub”>- tehokasta ja hellävaraista</p></div>;,
‘en’ => ‘Your text in english’
)
);best regards,
RainerOctober 11, 2014 at 10:47 am #334262Hi Rainer!
Unfortunately we don’t support CML and we don’t know how and if you can use this plugin with Enfold. We are also not familiar with the CML code and the plugin api.
Regards,
PeterOctober 13, 2014 at 10:39 am #334770Hi Peter,
Thanks for your answer anyways :-)
Yes, CML works fine with Enfold. I’ll continue to ask CML.Br, Rainer
ps. you can close this one.
I have found a solution to this problem and I just wanted to share it here for anyone else having the same problem. The code to add to the functions.php is the one below. You need to change the language codes according to your needs and of course the divs, classes and your text. Here you are:
To insert in the functions.php and modify according to your own language slugs and divs and css styles:
// Adds extra element to the header
add_action(‘ava_main_header’, ‘ava_cml_shortcode_text’);function ava_cml_shortcode_text(){
if(CMLLanguage::get_current_slug() == “sv”){
?>
<div class=’Your own’>
<p class=”Your own”>Your own text</p>
</div><?php
}elseif(CMLLanguage::get_current_slug() == “fi”){
?>
<div class=’Your own’>
<p class=”Your own”>Your own text</p>
</div><?php
}
}- This reply was modified 10 years ago by Lingvafix. Reason: Sharing the solution
-
AuthorPosts
- The topic ‘Language versions of text strings in header element’ is closed to new replies.