I have added a search bar for my woocommerce products page. Some searches go to archive-product.php and some go to single-product.php. I want to disable the single-product shortcut. I have tried searching my problem on stackoverflow and google but all I get is search filter plugins.
How do I stop my search from going to single products and automatically search on my inventory list page?
To simplify my problem here is how it looks:
When I search "wheel" :
When I search "air filter":
This is my search bar code:
<div class="search-wrap">
<form role="search" method="get" class="woocommerce-product-search" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<div class="search">
<label class="screen-reader-text " for="woocommerce-product-search-field-<?php echo isset( $index ) ? absint( $index ) : 0; ?>"><?php esc_html_e( 'Search for:', 'woocommerce' ); ?></label>
<input type="search" id="woocommerce-product-search-field-<?php echo isset( $index ) ? absint( $index ) : 0; ?>" class="search-field searchTerm" placeholder="<?php echo esc_attr__( 'Search products…', 'woocommerce' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
<button type="submit" class="searchButton" value="<?php echo esc_attr_x( 'Search', 'submit button', 'woocommerce' ); ?>"><i class="fa fa-search"></i>
</button>
<input type="hidden" name="post_type" value="product" />
</div>
</form>
</div>
2
Answers
Fixed by adding this into my functions.php
Answer found here: https://removewcfeatures.com/disable-woocommerce-single-search-result-redirect/
Add the following to functions.php
Tested on fresh install and works.