Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #163920

    Hi

    My website is http://career.guru99.com/

    now i have successfully add google custom search but look and feel of google custom search is not good as per as my requirement.

    here you can check what i actually want – http://screencast.com/t/rMZcLLlByV

    But in actual my google custom search look like this – http://screencast.com/t/aiski0jpI

    and i want google custom search here – http://screencast.com/t/fKSCOojxYc

    So please help me to do this

    #164052

    Hello kriru!

    Can you please add the google search? I don’t see it on the website.

    Best regards,
    Ismael

    #164067

    Ismael Please check – http://career.guru99.com/

    #164370

    Hello!

    You can use the wp_nav_menu_items filter to add list items to the menu. I.e. Kriesi uses this filter to add the search icon to the main menu. The code looks like

    
    	add_filter( 'wp_nav_menu_items', 'append_google_search_nav', 10, 2 );
    	function append_google_search_nav( $items, $args )
    	{		
    	    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=" data-avia-search-tooltip="'.$form.'">'.$avia_config['font_icons']['search'].'</a></li>';
    	    }
    	    return $items;
    	}
    

    – instead of

    
    	        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=" data-avia-search-tooltip="'.$form.'">'.$avia_config['font_icons']['search'].'</a></li>';
    

    insert your search form code – i.e.

    
    	        $items .= '<li id="menu-item-google-search">YOUR SEARCH FORM CODE</li>';
    

    and add the code to the bottom of functions.php.

    Cheers!
    Peter

    #165104

    I got this error while implement this. will you please tell me in detail

    #165128

    call_user_func_array() expects parameter 1 to be a valid callback, function ‘append_google_search_nav’ not found or invalid function name in E:\Guru99\xampp\htdocs\career99\wp-includes\plugin.php on line 173

    #165884

    Hi!

    You need to add in the function above and customize it for your specific google search code. So add this to your functions.php:

    
    	add_filter( 'wp_nav_menu_items', 'append_google_search_nav', 10, 2 );
    	function append_google_search_nav( $items, $args )
    	{		
    	    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-google-search">YOUR SEARCH FORM CODE</li>';
    	    }
    	    return $items;
    	}
    
    

    Where it says “YOUR SEARCH FORM CODE” you need to add the code for your search form.

    Best regards,
    Devin

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘How to customize google custom search?’ is closed to new replies.