Added a search to the Woocommerce menu with the following code:

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; } 

Everything works, searches for products, but the search results are displayed in Wordpress posts format, tell me how to make the output standard, as a list in any category of goods?

    1 answer 1

    At the root of your theme there is a search.php file. If not, create it. He is responsible for displaying the search results.

    It should be styled in the same form as the file /wp-content/themes/ваша-тема/woocommerce/archive-product.php . If you do not have such a file, take as a basis the file /wp-content/plugins/woocommerce/archive-product.php .

    But keep in mind that not only WooCommerce products will be included in the search results, but also other entries containing the search string.

    • thank you it displays already as it should, but the entire interface on the search results page was overcooked - user271244
    • to be more precise, nothing except the results is displayed, and the background color is different - user271244
    • stop, do you really need to connect styles to it? or add the file itself to some list with styles? search.php created by myself and copied the contents of archive-product.php - user271244
    • Styles do not need all the styles there. We must deal with the layout. I gave a general idea, it is necessary to finish it. So in the forehead, it is difficult to predict what modification will be needed. - KAGG Design
    • understood thanks. - user271244