Support » Theme: Spun » Adding search bar to menu
3 years, 8 months ago
I am trying to add a search bar to the nav_menu, by adding this to the bottom of functions.php however it will not display.
add_filter('wp_nav_menu_items','add_search', 10, 2);
function add_search($items, $args)
if( $args->theme_location == 'primary' )
return $items . '<li>'.get_search_form().'</li>';
Any ideas on way it seems to ignore this?
Theme location must be primary, meaning you have to actually setup the menu to the theme location.
Also the $echo in get_search_form( $echo ) must be false.
get_search_form( $echo )
But to be able to use get_search_form( false ) you need this fix which is now still in trunk.
get_search_form( false )
get_search_form() ignores $echo argument if searchform.php exists