How to Disable the WooCommerce Single Search Result Redirect

How to Disable the WooCommerce Single Search Result Redirect

ProductWriter.ai Logo Tired of struggling with your product descriptions? ProductWriter.ai can use your existing data and the power of artificial intelligence to write high-quality product descriptions for you in seconds. Get started for free!

WooCommerce comes out of the box with plenty of little “quality of life” interface improvements and adjustments for your visitors. These tweaks are meant to give customers the quickest route from browsing products, to adding them to their cart and checking out.

One of these improvements is how WooCommerce handles searches that return only one result. When there is only one product that matches a search query the user is not shown a search results screen at all. Instead, they are taken directly to the only product that matches what they were looking for.

For example, let’s say you only have one pair of sunglasses for sale in your store. If a user searches for “sunglasses” in your site’s search box they will be redirected straight to the Sunglasses product page.

The intention is to make your potential buyer have to take one less click than necessary to get to the product they want. But what if you don’t want that redirect to take place?

Maybe your search results page has shown, through your analytics, that people who visit tend to buy more than one product. In that case, you would want the people doing searches to see the results screen no matter what.

You can disable the WooCommerce single search result redirect with some code or by purchasing our plugin. We’ll walk you through the process with code first.


How to Remove the WooCommerce Single Search Result Redirect with Code

You can disable the WooCommerce single search result redirect from your site with just a few lines of code. Please make sure you follow these steps closely though. Doing something wrong can result in errors on your site and potential downtime.

Warning! Before you get started please make a full backup of your WordPress site. This will be important in case you make a mistake and need to go back to how your site was before you got involved. It’s also recommended you work on your local computer and never adjust files on a. live site.

Create a Child Theme

The WordPress theme system is very robust. One of the upsides is that you can download theme updates right inside of the admin. The downside of this is that any changes you make to your theme will be lost after each update. To work around this you have to make a child theme.

Child themes use a parent theme’s files as a base and then load its files on top of that. We can use this system to create changes to the parent theme and know that those changes will stay throughout any future updates. Follow this tutorial at WPBeginner to make your own child theme and then we can move on to dealing with actual code.

Add Code to a Child Theme

Your child theme needs a file called functions.php. This is where most common code changes and additions are placed in WordPress themes. If that file doesn’t exist you need to create it. Then open it up in a text editor and add the following lines of code to it:

add_filter( 'woocommerce_redirect_single_search_result', 'my_remove_search_redirect', 10 );
function my_remove_search_redirect() {
    return false;	 	 
}

When you have the above code snippet in place you can save the functions.php file. We’re done dealing with code. Now it’s time to get this child theme on your live site.

Upload Your Child Theme

You can get your new child theme on your WooCommerce store in one of two ways. The most common is to compress all of the child theme files and upload that through the WordPress admin. This can all be handled under the Appearance menu.

Another option is to use an FTP program and upload the files directly to the server. If you are unfamiliar with how FTP works your web hosting provider most likely has documentation to help you. It’s also possible you can find a freelancer to help you out with this as well.

Has this gotten a bit too technical for you? There is another way to deal with disabling the WooCommerce single search result redirect. It doesn’t involve creating themes, editing code, or uploading files. Jump ahead and learn how our plugin can help.

Active the Child Theme

Once the child theme has been successfully uploaded you need to turn it on. Head on over to the Appearance section of the WordPress admin to find your child theme. If it doesn’t show up anywhere you made a mistake during the upload process.

Activating the theme should have an immediate impact on your site. The WooCommerce single search result direct should be disabled. If the search result redirect still happens or your site is throwing errors there is a problem with the code in your child theme. Check out the code you added to the functions.php file and see if you made a typo or a mistake. When you’re sure it’s right upload and try again.

That was a lot of steps but you did it. You are now kind of a WordPress theme developer. If you’ve gotten this far but it still seems like a lot of work there is another choice. You can check out our Remove WooCommerce Features plugin and have it do all of the work automatically.


Stop the Single Search Result Redirect the Easy Way

We have developed a simple plugin that lets you turn off the single product search result redirect from your WooCommerce store.

Purchasing and installing our plugin is easy. You won’t have to make a child theme. Or open up a file in a text editor and write some code you don’t understand. There’s no testing to make sure your child theme is correct either. Our plugin handles all of this for you. We provide you with step-by-step instructions after purchase on how you can upload and activate the plugin. The whole process takes less than a minute.

All you have to do is install and activate our plugin. That’s really all there is to it. The plugin immediately disables the single result redirect process after it is activated. There are no settings. If you want to bring the redirect back all you have to do is deactivate the plugin.

Your plugin purchase comes with:

  • 90 days of support. Get help with your plugin up to three months after purchase.
  • No license keys or yearly subscriptions. Pay $14 once.
  • Unlimited installations. Install the plugin on as many sites as you want.

We offer a 14-day money-back guarantee. Get a full refund if you are unhappy with our plugin or if it doesn’t meet your expectations.