Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active December 17, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/5616867 to your computer and use it in GitHub Desktop.
Save braddalton/5616867 to your computer and use it in GitHub Desktop.
function add_search_box_secondary_menu($items, $args) {
if ($args->theme_location == 'secondary') {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
$items .= '<li class="searchbox">' . $searchform . '</li>';
}
return $items;
}
/**
* @author Brad Dalton - WP Sites
* @link http://wpsites.net/
*/
add_filter('wp_nav_menu_items','add_search_box_secondary_menu', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment