add search form to wordpress navigation menu

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

add search form to wordpress navigation menu

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

Search box on 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.

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *