Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #315698

    Hi,
    I would like to filter the main menu.
    Is it possible to use the add_filter( ‘wp_nav_menu_items’, ‘som_add_login_logout’, 10, 2 ); ?
    And also which is the name of the main theme location?

    thanks for support

    #316055

    Hi Gurify!

    Use this as a reference:

    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( '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 ((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;
    	}
    }
    

    Enfold uses that to attach the search to the menu.

    Cheers!
    Josue

    #316313

    ok thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Filter the main menu’ is closed to new replies.