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?

  • 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... – Mark Kaplun Dec 24 '15 at 5:46
  • If you want to fix the 404 try this code - stackoverflow.com/questions/28221920/… – Jon Jan 26 '18 at 11:55
4

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

  • 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 '15 at 14:54
  • What is your permalink structure under "Common Settings"? Can you please send me full screenshot of permalink settings page? – Prasad Nevase Dec 24 '15 at 15:23
  • 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 '17 at 19:04
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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