admin管理员组

文章数量:1122826

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

  • example/shop/ => Shop page listing products
  • example/shop/category-name/ => Category page listing products from a category
  • example/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?

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?

Share Improve this question edited Dec 24, 2015 at 0:21 Gabriel 2,24810 gold badges22 silver badges24 bronze badges asked Dec 23, 2015 at 17:26 Seb33300Seb33300 1691 gold badge1 silver badge4 bronze badges 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... – Mark Kaplun Commented Dec 24, 2015 at 5:46
  • If you want to fix the 404 try this code - stackoverflow.com/questions/28221920/… – Jon Commented Jan 26, 2018 at 11:55
Add a comment  | 

3 Answers 3

Reset to default 11

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

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

I trid the page:

  • https://my-site-name.com/product-category/iphones/ - I get SUCESS
  • https://my-site-name.com/product-category/iphones/iphone-16-pro/ - I get 404 NOT FOUND

The issue was that I did not created the category "iphone-16-pro" in Woocommerce, the solution is:

  1. Naviage to: Products > Categories
  2. Create a category named: "iPhone 16 Pro", slug: "iphone-16-pro"

It was solved.

本文标签: permalinksWooCommerce return 404 on category pages