5

I am trying to set up WooCommerce permalinks to get something like:

  • example.com/shop/ => Shop page listing products
  • example.com/shop/category-name/ => Category page listing products from a category
  • example.com/shop/category-name/product-name/ => Product page showing product details

But I have a 404 not found error when trying to open the category page.

What I did is:

  • I created a "Shop" page and I set it as the shop page in WooCommerce settings. OK: The page works fine and is displaying all products.

  • In WordPress permalinks settings, I set the product category base to "shop". KO: When I try to display a category page, WP returns a 404 error (but links are properly generated in the shop page sidebar and 404 error occurs while clicking on them).

  • In WordPress permalinks settings, I set the product permalink to "/shop/%product_cat%". OK: Products pages are displaying without issue.

Any way to solve this?

2
  • It is impossible to answer "something do not work as expected" type of quetions without full details about your settings. Did you try to turn off plugins, switch theme? anything interesting about your server setup? etc... Dec 24, 2015 at 5:46
  • If you want to fix the 404 try this code - stackoverflow.com/questions/28221920/…
    – Jon
    Jan 26, 2018 at 11:55

2 Answers 2

9

Under Custom Base where you have used /shop/%product_cat% needs to be replaced with /shop/%product-category% Please see screenshot below:

enter image description here

4
  • 3
    Now, I can see the category listing page, but when clicking on a product, I have a "400 bad request error" because the called url is: /shop/%product-category%/product-name/ (%product-category% is not replaced by the category name)
    – Seb33300
    Dec 24, 2015 at 14:54
  • What is your permalink structure under "Common Settings"? Can you please send me full screenshot of permalink settings page? Dec 24, 2015 at 15:23
  • 1
    Can't find anything on this exact issue. For me as well, when I add %product-category% to the custom base, fixes the category pages, but the literal variable name %product-category% is outputted in the product permalinks instead of the category (/shop/%product-category%/products-name/)
    – i_a
    May 15, 2017 at 19:04
  • This solution works. For whatever reason, using %product-category% in the Custom Base area of Product Permalinks Base fixes the Product Category Base issue. However, that then breaks the product permalinks. :(
    – Nathan
    Apr 26, 2021 at 14:41
1

Turns out you don't need to use %product-category% as this does create an issue with the permalinks, that variable name is left in the links, and not the actual product category.

Just leave Category base blank, that is what seems to have been causing the 404 error conflict. With the settings below, all is working:

example.com/store/ => Shop page listing products

example.com/store/category-name/ => Category page listing products from a category

example.com/store/category-name/product-name/ => Product page showing product details

enter image description here

2
  • Leaving Product category base blank now results in Woo forcing it to be product-category
    – Nathan
    Apr 26, 2021 at 14:40
  • 1
    Yes, what Nathan said is exactly the problem in the end. Still no solution. You either have working product links, or correctly formatted category links but not both. Aug 14 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.