In many wordpress premium theme search form added in navigation menu and many clients are demanding for same So here we created tutorial for adding search form.
WordPress tutorial for, add search form to wordpress navigation menu. If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file.
add search form to wordpress navigation menu
Using following code in you can add the search form in your menu bar.
function add_search_box($items, $args) { ob_start(); get_search_form(); $searchform = ob_get_contents(); ob_end_clean(); $items .= ' <ul> <ul> <ul> <li class="search-form">' . $searchform . '</li> </ul> </ul> </ul> '; return $items; } add_filter('wp_nav_menu_items','add_search_box', 10, 2);
There is very nice wordpress plugin which will add search box in navigation menu.
Search box on Navigation Menu
This plugin will add the default search box on main navigation menu that will save the space and flexibly fit with the menu.
Great article. Saved my time. I can able to add the search form in top menu of wordpress.