I'm using WooCommerce on a WordPress. I would like my products and product categories to have the same url base. E.g.
www.example.com/shop/product-category
www.example.com/shop/sample-product
Using this code here:
add_filter( 'rewrite_rules_array', function( $rules )
{
$new_rules = array(
'shop/([^/]*?)/page/([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&paged=$matches[2]',
'shop/([^/]*?)/?$' => 'index.php?product_cat=$matches[1]',
);
return $new_rules + $rules;
} );
I changed the permalinks in Settings > permalink:
Custom Structure: /shop/%postname%/
Product category base: shop
Custom base: shop
then when visit each of the following pages, I get the following result:
Custom Structure: works
Product category base: works
Custom base: 404 error
Anybody have any insight on how to get the single product pages to not throw the 404 error?
Thanks!