Disable Redirect to Product Page on Search Results Page in WooCommerce

In WooCommerce if you search for a product and there is only one search result then WooCommerce will redirect you directly to the product page. If I want to add some fancy styling to the search results page is there a way I can disable this default functionality?

Related posts

1 comment

  1. Yes, this is totally possible. WooCommerce includes a handy filter that you can manipulate to disable that redirect so the user will continue onto the search results page as per normal.

    If you add this line of code to your functions.php file it will disable the redirect functionality.

    add_filter( 'woocommerce_redirect_single_search_result', '__return_false' );
    

    Permalink to gist: https://gist.github.com/BFTrick/6429700

Comments are closed.