You can add any item you want to a menu by filtering wp_nav_menu_items
.
From the tutorial How to Add a Search to Menu, this is how you’d add a search form:
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
$searchform = get_search_form( false );
$items .= '<li>' . $searchform . '</li>';
return $items;
}
Related Posts:
- Customizing Only a Specific Menu using the “wp_nav_menu_items” Hook?
- wp_nav_menu: show menu only if one exists, otherwise show nothing
- Custom search filter causes menu and query_posts problems
- wp_nav_menu() not working on Custom Search Page
- Add class to all list items of wp_nav_menu
- Number of items in a menu
- Where do custom menus get constructed?
- Create search form in menu as in Twenty Fourteen theme
- get_search_form() doesn’t appear to take parameter into account
- How do I apply a class to custom menu items based on user roles
- Change an li class name in a wordpress custom menu walker
- Custom Links menu items include in Search Results
- How to add search to menu?
- Admin: WooCommerce Navigation Menus do not show empty categories search tab
- How to get the title of root li element
- How To Add Class To Style Search Box
- After WordPress 4.8 upgrade, wp_nav_menu() string search / replace not working
- Hiding Widget On Mobile Devices Removes Our Product Search Box On Mobiles
- Using a menu walker add a custom item at the end of the menu’s items
- Show current navigation path from menu
- Menu items (all menus) being deleted randomly on their own [duplicate]
- How do I fix this error: Warning: invalid argument supplied for foreach()?
- Exclude one item from wp_list_pages( $args );
- Put a wp_nav_menu inside another one
- different Menu position showing same menu
- How to add bubble count in WordPress wp_nav_menu menu?
- Add class to active top level (grandparent) menu item
- Check if wp_nav_menu items have submenus
- How to conditionally register nav menus with advanced custom fields?
- Use walker for specific menu, or avoid use of walker
- Change where navigation bar links?
- Sort wp_nav_menu() by menu order
- How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
- How to give custom classes to the WordPress Menu widget
- No “current-menu-ancestor” class added when browsing an archive page
- Does wp_nav_menu use the gettext filter?
- How to add #navbar to all page links?
- Problems Displaying Multiple WP Menus
- View h2 content tags of a page in sub menu
- How to add custom classes to more than one separate menu’s a link in wordpress?
- add_submenu_page function to show videos table
- Menu item with no page, but with dropdown
- How to test if blog page is active
- WordPress Custom Menus Issue
- Side Menu Icon Expandable
- wordpress responsive menu not dropping down
- WordPress Plugin menu position overwrite other item
- How to use a start_el variable in start_lvl
- Need Random Category Nav Menu
- edit user menu item
- Excluding a media query from specific pages
- Menu Arrow for Child Element
- Custom menu with different behavior for every item
- Problem in applying active class to wordpress menu
- How to get submenu dropdown with images?
- Walker Class: Output Parent Description and Featured Image right after sub-menu?
- Modifying the walker to insert parent’s description above sub menus
- wp_list_pages Hierarchical Help
- How to avoid the and which added when custon menu widget is used
- How to create a complete mulilanguage site using xili language plugin?
- Updated WordPress, now Navigation is Messed Up
- wp_nav_menu removing containing UL with ‘items_wrap’ => ‘%3$s’ not working
- How to show only current item children using wp_nav_menu?
- Possible to append class to nav menu added to widget area?
- Copied site has wrong menu URL behaviour
- Removing wp admin menu item on top bar of admin backend
- Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()
- Nav_walker add id to dropdown ul
- Navbar is hidden behind carousel when using wp-boostrap-navwalker
- WordPress nav-menus not finding page
- Primary menu items are dissapearing
- Active Current Menu – Adding class to child theme
- display cart information within li of cart menu item
- WPML CMS Nav and Custom Nav_Walker Undefined Property Notices [closed]
- Add data-track to links in menu
- Is it possible to seperate wordpress menu by different div?
- How to add odd and even classes to all nav links through walker?
- Output sort number in wp menu list item?
- Check in walker if current page is descendant
- Add a non-dynamic phrase/character after a page title?
- how to display wordpress navbar with top menu outside wordpress system
- Active page link not getting class assigned
- Removing menu item doesn’t get removed on edit post
- change link of menu particular tab
- Menus not showing in the admin menu, after save
- Customize Walker_nav_menu to show posts if item is category
- Top menu link anchor href value change after online server?
- Add Protocol to Custom Menus
- How to handle change the appearance of ‘categories’ box on dashboard?
- How can I stop wp_nav_menu from returning extraneous root links?
- How to add posts with thumbnails to my dropdown menu?
- Change menu item order
- Menu System: Custom Links
- Formatting WordPress Menus (without bullets, inline with text)
- Change Menu Order
- Two Homes In Navigation Menu
- Theme supports only one menu. I need to add more – but how? [closed]
- Sub menu for a (single) page
- Add acf custom fields so sub item in menus
- change breakpoint widths for divi theme tablet view