Add Searchbox to Navigation

Supplemental 34 views
0
0 Flares 0 Flares ×

This adds a search box in a list item at the end of your navigation.

<?php
function so_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','so_add_search_box', 10, 2);
?>
Provided by: Piet Bos
Tagged with:
Posted in Wordpress

Discuss:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

No Trackbacks.

Login

Register | Lost your password?
0 Flares Twitter 0 Facebook 0 Google+ 0 0 Flares ×