Skip to content

Instantly share code, notes, and snippets.

@katmoody
Last active August 29, 2015 14:09
Show Gist options
  • Save katmoody/162a4058ea604df63eca to your computer and use it in GitHub Desktop.
Save katmoody/162a4058ea604df63eca to your computer and use it in GitHub Desktop.
Adds search form to Specific Navigation with Theme Location - Replace "example.com" with your site's primary URL
add_filter('wp_nav_menu_items', 'add_search_form', 10, 2);
function add_search_form($items, $args) {
if( $args->theme_location == 'secondary' )
$items .= '<li class="search"><form method="get" class="search-form" action="http://example.com/" role="search"><input type="search" name="s" placeholder="Search..."><input type="submit" value="Search"></form></li>';
return $items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment