Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

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.

This topic contains 6 replies, has 2 voices.

Last updated by Harshad 7 years, 8 months ago.

Assigned support staff: Harshad.

Author Posts
June 15, 2012 at 5:44 pm #63335

Carme

Hello,
I have my language switchers in the header area of my website. I need to change that and put in horizontal position. Can you help me with that?

I look forward to hearing from you
thanks
xxx

June 16, 2012 at 6:58 am #63361

Harshad

Dear Carme,

Add the following code to your theme's functions.php file.

function language_selector_flags(){
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0&orderby=code&order=desc');
if(!empty($languages)){
foreach($languages as $l){
if(!$l['active']) echo '<a href="'.$l['url'].'">';
echo '<img src="'.$l['country_flag_url'].'" alt="'.$l['language_code'].'" /> '.$l['native_name'];
if(!$l['active']) echo '</a>';
}
}
}
}

Then add the following code into your theme's header.php file

<?php language_selector_flags()?>
June 17, 2012 at 11:03 am #63466

Carme

Hi Harshad,
It happens to me the same as last week,
This is my admin page now:
function language_selector_flags(){ if (function_exists('icl_get_languages')) { $languages = icl_get_languages('skip_missing=0&orderby=code&order=desc'); if(!empty($languages)){ foreach($languages as $l){ if(!$l['active']) echo '<a href="'.$l['url'].'">'; echo '<img src="'.$l['country_flag_url'].'" alt="'.$l['language_code'].'" /> '.$l['native_name']; if(!$l['active']) echo '</a>'; } } } }
Warning: Cannot modify header information - headers already sent by (output started at /home/karmebac/public_html/carmeba.com/wp-content/themes/atahualpa/functions.php:994) in /home/karmebac/public_html/carmeba.com/wp-includes/pluggable.php on line 866

I am going to add the previous php files because I need my website on line, but I would like to know where I need to add this code, I added both of them at the bottom of the doc.
I look forward to hearing from you

Carme
xXx

June 17, 2012 at 12:32 pm #63471

Harshad

Remove the white spaces at the end of your functions.php file before ?>

June 17, 2012 at 3:10 pm #63498

Carme

Hi,
I coudn't find this white spaces at the end of the functions.php

this is how it looks the end of my functions.php file:
Would you want me to remove the two lines before ?> with that:
}
}

/*Adding code for flag selectors -WPML plugin*/
function language_selector_flags(){
$languages = icl_get_languages('skip_missing=0&orderby=code');
if(!empty($languages)){
foreach($languages as $l){
if(!$l['active']) echo '<a href="'.$l['url'].'">';
echo '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" />';
if(!$l['active']) echo '</a>';
}
}
}
?>
function language_selector_flags(){
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0&orderby=code&order=desc');
if(!empty($languages)){
foreach($languages as $l){
if(!$l['active']) echo '<a href="'.$l['url'].'">';
echo '<img src="'.$l['country_flag_url'].'" alt="'.$l['language_code'].'" /> '.$l['native_name'];
if(!$l['active']) echo '</a>';
}
}
}
}

June 17, 2012 at 3:19 pm #63501

Carme

The end of my header php file looks like that:

<!-- Main Column -->

<td id="middle">
<?php language_selector_flags()?>

and the end of the functions.php like that:
/*Adding code for flag selectors -WPML plugin*/
function language_selector_flags(){
$languages = icl_get_languages('skip_missing=0&orderby=code');
if(!empty($languages)){
foreach($languages as $l){
if(!$l['active']) echo '<a href="'.$l['url'].'">';
echo '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" />';
if(!$l['active']) echo '</a>';
}
}
}
?>
function language_selector_flags(){
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0&orderby=code&order=desc');
if(!empty($languages)){
foreach($languages as $l){
if(!$l['active']) echo '<a href="'.$l['url'].'">';
echo '<img src="'.$l['country_flag_url'].'" alt="'.$l['language_code'].'" /> '.$l['native_name'];
if(!$l['active']) echo '</a>';
}
}
}
}

I tried again but it didn't work 🙁

I look forward to hearing from you
xxx

June 18, 2012 at 8:21 am #63558

Harshad

Dear Carme,

Can you please send me your ftp and wp-admin details to my email address?

The topic ‘[Closed] How to create a horizontal Language Switcher’ is closed to new replies.