Maybe because you have only one product category and therefore search engines would find duplicate content (Shop page = Category page) and penalize your website.
Or maybe because you use advanced product filters and you prefer customers to see the filtered view “by category” (e.g. “example.com/shop/?_product_category=tables“) as opposed to the default category pages ( “example.com/product_category/tables” ).
Either way, it is possible to programmatically redirect all product category pages to a given page or to a relevant URL with parameters – and here’s the fix. Enjoy!
PHP Snippet 1: Redirect All Product Category Pages to Shop Page
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: Custom Add to Cart URLs – The Ultimate Guide In WooCommerce you can add a product to the cart via a custom link. You just need to use the “add-to-cart” URL parameter followed by the product ID. This tutorial will show you how to create custom URLs to add simple, variable and grouped products to the cart – as well as defining the add […]
WooCommerce: Add Second Description @ Product Category Pages In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
WooCommerce: Show Category For Each Product @ Shop Page A client of mine has a category called “Brand”. Each product is assigned to a specific Brand subcategory e.g. Nike, Adidas, etc. The goal of this task was to show the “Brand” subcategories in the shop/category/loop pages as a way to help the user identify the brand name. The same can be applied to showing […]
WooCommerce: Should I Noindex Product Tag Pages? Ah, yet another million dollar question. If you have organized your WooCommerce products properly, you have “N” product categories and “M” product tags, where “M > N” (actually, if there were such a thing in algebra, it should be “M >>> N” as each product should be assigned to 1 category and multiple tags). This […]
WooCommerce: Change Product Permalinks @ Shop / Loop Pages A BloomerArmada fan asked me a very interesting question: how can I link each product in the shop page to its own custom landing page as opposed to the default permalink? Of course this applies when you don’t want to use the default single product page for all or some products. Clearly, you could set […]
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
6 thoughts on “WooCommerce: Redirect Product Category Pages”
phKoon
Hello there! Thanks for this!!
It happens I need to do the samething for a custom taxonomy I created for products as well.
I was able to get it working for product categories even with custom slugs, applying the following modifications:
But couldn’t do the same for a custom taxonomy (“ambient” for example).
Would you happen to know how could I do so, what paremeters I nedd to change or what’s the structure logic for custom taxonomies?
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!
Hello there! Thanks for this!!
It happens I need to do the samething for a custom taxonomy I created for products as well.
I was able to get it working for product categories even with custom slugs, applying the following modifications:
But couldn’t do the same for a custom taxonomy (“ambient” for example).
Would you happen to know how could I do so, what paremeters I nedd to change or what’s the structure logic for custom taxonomies?
Thanks in advance!
Thank you! I believe https://developer.wordpress.org/reference/functions/is_tax/ should help
Thank you! Works great!
How do i redirect it to the category on the shop page. now it only redircts to the shop page.
Not sure I follow
Great snippet.
I would suggest using
in the conditional check. Otherwise when using a category filter on the back-end for products, it will redirect you to the front-end shop page.
E.g.
Fantastic, thank you