Thanks to some help on here, I've managed to add a custom search box to my main menu... by adding this to my theme's functions.php
add_filter('wp_nav_menu_items','search_box_function');
function search_box_function ($nav){
return $nav."<li class='menu-header-search'><form action='http://example.com/' id='searchform' method='get'><input type='text' name='s' id='s' placeholder='Search'></form></li>";
}
However, I've now added another menu to put in the footer, but the search box gets added to this one too. How would I add the search box to the primary menu only?
My code for registering the menus is:
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'twentyten' ),
'secondary'=>__('Secondary Menu', 'twentyten' ),
) );
..and the code to display the secondary menu is:
wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'secondary' ) );