WordPress.org

Support

Support » Plugins and Hacks » Polylang » [Resolved] Is it possible to display a language switcher in de beginning from menu?

[Resolved] Is it possible to display a language switcher in de beginning from menu?

Viewing 2 replies - 1 through 2 (of 2 total)
  • It’s possible with a little “hack”, you can add this to your functions.php, works with “TwentyTen”, did not test with “Responsive 1.8.5” theme…

    // adds the polylang language switcher at the beginning of the menu
    function ov3rfly_nav_menu_items($items, $args) {
    	global $polylang;
    	$menu_lang = get_option('polylang_nav_menus');
    	return isset($polylang) ?
    		$polylang->the_languages(array_merge($menu_lang[$args->theme_location], array('menu' => 1, 'echo' => 0))) . $items : $items;
    }
    add_filter('wp_nav_menu_items', 'ov3rfly_nav_menu_items', 10, 2);

    You can not switch this on and off via Polylang “Menus” settings, it will always be there if Polylang plugin is active.

    Settings like “Displays flags” etc. from Polylang “Menus” settings are used.

    The “hack” is based on code from polylang/include/core.php

    Thx this works for me !
    Its also working with theme Responsive v 1.8.5

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Is it possible to display a language switcher in de beginning from menu?’ is closed to new replies.
Skip to toolbar