Skip to content

Instantly share code, notes, and snippets.

@dcatkins40
Created January 21, 2013 15:17
Show Gist options
  • Select an option

  • Save dcatkins40/4586767 to your computer and use it in GitHub Desktop.

Select an option

Save dcatkins40/4586767 to your computer and use it in GitHub Desktop.
PHP code to place a search bar into the nav menu as a li. Pulls the search bar from search.php.
/*Wordpress
functions.php*/
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
$items .= '<li class="navSearch">' . $searchform . '</li>';
return $items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment