public
Created

add search box to navigation bar

  • Download Gist
search-to-nav.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
// ADD SEARCH BOX TO NAVIGATION
function add_search_box($items, $args) {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
$items .= '<li class="nav_search">' . $searchform . '</li>';
return $items;
}
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
// END ADD SEARCH BOX
?>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.