Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #378756

    Would you please tell me how to paste the language switcher into the main header area
    just align right to the menu and search icon

    like this : https://copy.com/GU49TtBp6l9nCPZ1

    Thanks a lot!

    #378768

    Hey akzleung!

    Can you post the link to your website please? We may need a temporary admin login as well. Where have you added polylang code?

    Best regards,
    Yigit

    #378852
    This reply has been marked as private.
    #379245
    This reply has been marked as private.
    #379266

    Hello,

    Polylang switcher can be added to the menu from here (it is added right now). If you need a more complex implementation you’ll need to write some code, there is a WordPress filter you can use to append additional content to the main menu (we use this for the search icon, functions-enfold.php:56):

    add_filter( 'wp_nav_menu_items', 'append_polylang_func', 100, 2 );
    
    function append_polylang_func ( $items, $args )
    {	
    	$items .= "Polylang language switcher function here";
        return $items;
    }

    Here’s some reference to the Polylang language filter function and its parameters:
    https://polylang.wordpress.com/documentation/frequently-asked-questions/the-language-switcher/
    https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/

    Regards,
    Josue

    #379344
    This reply has been marked as private.
    #379579

    Hey Akzleung!

    To which file did you add the code?

    Regards,
    Josue

    #379868
    This reply has been marked as private.
    #379871
    This reply has been marked as private.
    #380558

    Hi Akzleung!

    I’m unable files from the Dashboard, try changing your code to:

    if(!function_exists('avia_append_search_nav'))
    {
    	//first append search item to main menu
    	add_filter( 'wp_nav_menu_items', 'avia_append_search_nav', 10, 2 );
    
    	add_filter( 'wp_nav_menu_items', 'append_polylang_func', 100, 2 );
    
    	function append_polylang_func ( $items, $args )
    	{	
    		if ((is_object($args) && $args->theme_location == 'avia') || (is_string($args) && $args = "fallback_menu"))
    		{
    		$items .= '<div class="lang_switcher_polylang">'.pll_the_languages()."</div>";
    		}
    	    return $items;
    	}
    	add_filter( 'avf_fallback_menu_items', 'avia_append_search_nav', 10, 2 );
    
    	function avia_append_search_nav ( $items, $args )
    	{	
    		if(avia_get_option('header_searchicon','header_searchicon') != "header_searchicon") return $items;
    		if(avia_get_option('header_position',  'header_top') != "header_top") return $items;
    	
    	    if ((is_object($args) && $args->theme_location == 'avia') || (is_string($args) && $args = "fallback_menu"))
    	    {
    	        global $avia_config;
    	        ob_start();
    	        get_search_form();
    	        $form =  htmlspecialchars(ob_get_clean()) ;
    
    	        $items .= '<li id="menu-item-search" class="noMobile menu-item menu-item-search-dropdown">
    							<a href="?s=" rel="nofollow" data-avia-search-tooltip="'.$form.'" '.av_icon_string('search').'><span class="avia_hidden_link_text">'.__('Search','avia_framework').'</span></a>
    	        		   </li>';
    	    }
    	    return $items;
    	}
    }

    Cheers!
    Josue

    #380595
    This reply has been marked as private.
    #382014

    Hi!

    You needed to pass the echo=0 argument to the pll_the_languages function so it doesn’t automatically shows, check it now. I also added this to Quick CSS:

    .lang_switcher_polylang {
        position: absolute;
        top: 0;
        right: -100px;
    }
    .lang_switcher_polylang li{
    	display: block;
    	float: none;
    }
    .av-main-nav {
        position: relative;
        right: 100px;
    }

    Cheers!
    Josue

    #382333

    Hi Josue,

    It works!
    Thank you very much for your time and all your support team!

    Best wish,
    Akzleung

    #382346

    You are welcome Akzleung, always glad to help :)

    Regards,
    Josue

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.