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.

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

This topic contains 5 replies, has 3 voices.

Last updated by Mina 7 years, 6 months ago.

Assigned support staff: Harshad.

Author Posts
September 17, 2012 at 9:49 pm #75594

David

Hi,

how can I remove the language names in the language switcher (in the WordPress menu)? I only want to display the flags.

I can't set it up in the WPML settings... perhaps a bug?

Cheers
David

September 18, 2012 at 2:18 am #75605

Mina

Hello,
I need to do the same thing , and also i want to know how can put each flag as button separated not in list .

thanks

September 18, 2012 at 5:20 am #75626

Harshad

Guys,

The code below will add VERTICAL language switcher with flags only to your main menu.
Please add the code, to your themes functions.php file.

function new_nav_menu_items($items,$args) {
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0');
if(1 < count($languages)){
foreach($languages as $l){
if($l['active']){
$items .= '<li class="menu-item menu-item-language menu-item-language-current"><a href="#" onclick="return false"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" class="iclflag"/></a><ul class="sub-menu submenu-languages">';
}
else
{
$items .= '<li class="menu-item menu-item-language menu-item-language-current"><a href="'.$l['url'].'"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" class="iclflag"/></a></li>';
}

}
$items .= '</ul></li>';
}
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );
September 18, 2012 at 5:43 am #75629

Mina

Hello again,
thanks Harshad for your fast answer

Could you please help me how to add the flags horizontal in my main ?

thank you!!!

September 18, 2012 at 6:19 am #75632

Harshad

Dear Mina,

For horizontal language switcher use below code.

function new_nav_menu_items($items,$args) {
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0');
if(1 < count($languages)){
foreach($languages as $l){
if(!$l['active']){
$items = $items.'<li class="menu-item"><a href="'.$l['url'].'"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /></a></li>';
}
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );
September 18, 2012 at 12:24 pm #75704

Mina

thank you, it´s working!!!!

The topic ‘[Closed] Only flags in WordPress menu’ is closed to new replies.