Skip to content

Instantly share code, notes, and snippets.

@rsharrer
Created September 26, 2013 13:54
Show Gist options
  • Select an option

  • Save rsharrer/6714582 to your computer and use it in GitHub Desktop.

Select an option

Save rsharrer/6714582 to your computer and use it in GitHub Desktop.
Add search form to specific wp_nav_menu
add_filter('wp_nav_menu_items', 'add_search_form', 10, 2);
function add_search_form($items, $args) {
if( $args->theme_location == 'MENU-NAME' )
$items .= '<li class="search"><form role="search" method="get" id="searchform" action="'.home_url( '/' ).'"><input type="text" value="search" name="s" id="s" /><input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" /></form></li>';
return $items;
}
@jeremytarpley
Copy link

awesome, worked perfectly - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment