Hi, Amit here, I am the WPML Support Manager, our current ticket queue is quite calm and I'd like to encourage you to use our new chat support option

We are working hard to debug and look at every single report

All of the known issues are documented in https://wpml.org/known-issues/ you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

We are also adding once a week a tutorial to our YouTube channel - https://www.youtube.com/c/WPML-multilingual - check out if we already covered what you need and leave us a comment if you want us to produce anything there

If you do need to open a ticket please make sure to provide us with all the needed information as described here https://wpml.org/faq/checklist-before-opening-a-ticket-in-wpml-support/

We are very proud at our level of support, we are one team from all over the world and we are all experienced WordPress developers, you can read more about us here - https://wpml.org/forums/supporters/

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 5 replies, has 3 voices.

Last updated by Audun 5 years, 5 months ago.

Assigned support staff: Harshad.

Author Posts
July 4, 2013 at 7:15 am #141481

Marc

Hi,

I have used the following code within my function.php theme file and it works just perfect! problems it also appears on my sidebar menus.... could you help in putting the only flag language filter in the header instead ? Thank you advance.

the website I am developing : hidden link

code I have used and put in the function.php:

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>';
}
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );

?>

July 4, 2013 at 9:06 am #141536

Harshad

Dear Marc,

Can you please add following line

echo $args->theme_location;

just after

function new_nav_menu_items($items,$args) {

Then reload the front page, and see what output you get, just paste the output here.

July 4, 2013 at 10:38 am #141571

Marc

Hello HArshad,

adding the line of code did not change anything. but I have the innactive grey text"alertna_menu" that appears right above my menu. In fact I suggest 2 options:

1) I put the flags only in the header
2) I put the flags only in the main menu but not the sides menu (whichever is the simple one)

Just to make sure below is the the completed code I have added to my function.php of my theme. Thank you Harshad!

function alterna_login_logo_url_title() {
return get_bloginfo('title');
}
add_filter( 'login_headertitle', 'alterna_login_logo_url_title' );
function new_nav_menu_items($items,$args) {echo $args->theme_location;
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>';
}
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'new_nav_menu_items',10,2 );

?>

July 4, 2013 at 11:08 am #141581

Harshad

Please use the revised code below:

function new_nav_menu_items($items,$args) {
if (function_exists('icl_get_languages')) {
if ($args->theme_location == 'alertna_menu') {
$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 );
July 4, 2013 at 11:48 am #141608

Marc

Thank you Harshad! You're the best! you solved my problem!!!!!!! everything works exactly like I wanted!

August 17, 2013 at 2:52 pm #155442

Audun

Hi
I've just installed the WPML for blog plugin. And want to have a language switcher appearing in the right part of the header of the website - Twentythirteen theme.

I tryed to put in the code above from Harshad into my function.php file at the end. It resulted in an error.

Do you have suggestion for code just to put in (I dont know coding myself) to get the three language flags side by side in the right lower area of the header?

Thanks in advance 🙂