0

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!

1
  • Help me, please!
    – Paweł
    May 23, 2023 at 7:56

1 Answer 1

0

Lots of people dealing with the same issue and I haven't found a solution yet either. It's like the whole thing is broken and most people just don't care?

Your Answer

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

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