Y
Y
YakovSpb2020-06-22 20:23:47
WordPress
YakovSpb, 2020-06-22 20:23:47

How to replace default Wordpress search with Woocommerce search?

I need to display the search in the last item of the top menu. Found the code, but there is a standard search.
How do I display woocommerce search?

in function.php registered

// начало кода формы поиска в меню
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
$items .= '<li class = "my_search">' . $searchform . '</li>';
return $items;
}
// конец кода формы поиска в меню

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2020-06-23
@loonny

Use get_product_search_form() instead of get_search_form() to display the form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question