I am using this code in my top menu (function.php
). But through this code the search bar will display at the end of the menu (i.e. the last li
).
How can I change the ordering? I have to place it in the first li
. Is it possible or not?
/**
* Add search box to primary menu
*/
function wpgood_nav_search($items, $args) {
// If this isn't the primary menu, do nothing
if( !($args->theme_location == 'topmenu') )
return $items;
// Otherwise, add search form
return $items . '<li class="search-in-menu"><p id="hm-search1"><i class="fa fa-search"></i></p>' . get_search_form(false) . '</li>';
}
add_filter('wp_nav_menu_items', 'wpgood_nav_search', 10, 2);