Language flags in menu and W3C


  • Member
    drunkfox
    March 1, 2013 at 12:41 pm #14370

    Hello. I would like to have the WPML language selector (only flags) in the menu.
    To do that, I must insert the following code in the functions.php file.
    It work fine but unfortunately there are 6 validation errors, that’s because the flags is added in “select…” “/select” tags.

    Please, do you know if is possible to to avoid these problems?

    This is the code that I put in the functions.php file:

    // Filter wp_nav_menu() to add additional links and other output
    function new_nav_menu_items($items) {
    if (function_exists(‘icl_get_languages’)) {
    $languages = icl_get_languages(‘skip_missing=0′);
    if(1 < count($languages)){
    foreach($languages as $l){
    if(!$l){
    $items = $items.’

  • ‘;
    }
    }
    }
    }

    return $items;
    }
    add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items’ );

    Thank you.

Sorry, this forum is for verified users only. Please Login or Register to continue