If using a child theme, you can add a search bar to your secondary menu by adding this function to your functions.php file. If not, you can also utilize the code-snippets plugin.
add_filter('wp_nav_menu_items', 'custom_add_search_form_to_second_menu', 10, 2); function custom_add_search_form_to_second_menu($items, $args) { if( !($args->theme_location == 'secondary_navigation') ) return $items; ob_start(); ?> <li class="menu-search-icon-kt"> <a class="kt-menu-search-btn collapsed" title="<?php echo __('Search', 'virtue');?>" data-toggle="collapse" data-target="#kad-menu-search-popup"> <?php echo __('Search', 'virtue');?> </a> <div id="kad-menu-search-popup" class="search-container container collapse"> <div class="kt-search-container"> <?php get_search_form(); ?> </div> </div> </li> <?php $output = ob_get_contents(); ob_end_clean(); return $items . $output; }
If you wish to instead use a WooCommerce search, change the
get_search_form();
to
get_product_search_form();
To learn more about and download a free child theme, visit this child theme tutorial.