Hi Tom,
I want to keep the fixed option for my primary nav but move the search feature inside the secondary nav.
Browsing through the forum I saw this code to insert a search field inside my secondary menu
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
if( $args->theme_location == 'secondary') {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
$items .= '<li class="search-item" title="Search"><a href="#"><i class="fa fa-fw fa-search" aria-hidden="true"></i><span class="screen-reader-text">Search</span></a></li>';
}
return $items;
}
It outputs a full search form, but I’d prefer to replicate the exact same behaviour than the default search feature in the primary nav (a search icon that reveals the search field on click).
What is the best way to do it?