WooCommerce: Redirect Specific Product Search To Custom URL
Go to a WooCommerce website. Search for a product. Get to the search results page, which displays from 0 to N products based on the search term, sorted by relevancy. Easy.
Now, let’s imagine you have a custom landing page for “Tables”, and you want people searching for “tables” to go to that page instead of the default search result page. Quite easy as well – thanks to a neat PHP snippet we will feature today.
Enjoy!
PHP Snippet: Redirect Specific Search Term Result to a Custom URL @ WooCommerce Frontend
This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101
Related content
WooCommerce: Add a Product Search Bar in the Header/Footer Hola amigos, today’s snippet actually comes from my own website. You might have noticed there is a little “magnifying glass” in the navigation menu which scrolls down to a search bar. Mine, specifically, searches exclusively for blog posts (I excluded pages, products, etc.), but you can customize this and make it search for products only […]
WooCommerce: Search Products By SKU (Frontend) The frontend WooCommerce product search, for some reason, doesn’t work for SKU values. If it does, then your theme developers were smart enough to include this in their code, because this is a big problem especially for B2B stores. Today, we’ll study how to alter the product search query, as well as the wc_get_product_id_by_sku() function, […]
WooCommerce: Search Orders By SKU @ Admin Exactly. By default, when you search for orders in the WordPress > WooCommerce > Orders backend, using a SKU will give you 0 results. Which is pretty poor for a store manager. Let’s change this. Despite the code is a little complex, all you need is a simple copy & paste. Enjoy!
WooCommerce: Search Products By Custom Field (Backend) In WooCommerce, there are two kinds of search: the customer one (frontend) and the admin one (backend). We’ve already covered how to let customers search into custom field values on top of the default product title and description, so this time we’ll talk about the backend search. Let’s say, as a WooCommerce store admin, that […]
WooCommerce: How to Show Product Search Suggestions? “Ajax Search” (displaying product search suggestions while a WooCommerce user is typing something in the search bar), is a brilliant idea for all of you ecommerce entrepreneurs. Saving time to a potential customer is your number one goal. Besides, if your website has a lot of traffic, search should be one of your sales propositions […]
Rodolfo Melogli
Business Bloomer Founder
Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli
Questions? Feedback? Customization? Leave your comment now! _____
If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!