WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Is it possible to display a language switcher in de beginning from menu? (3 posts)

  1. carel1961
    Member
    Posted 1 year ago #

    Is it possible to display a language switcher in de beginning from menu?
    Default is at the end, but I like to have at the beginning.

    I use theme Responsive v. 1.8.5

    http://wordpress.org/extend/plugins/polylang/

  2. Ov3rfly
    Member
    Posted 1 year ago #

    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

  3. carel1961
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic