0

I have a custom post type (products) that I would like to change the slug for. I have a main product page that shows all product categories. After clicking on the category, it shows all products in that category. When clicking on one of the products it should take you to the custom post type product. The problem is that I want the url to be www.example.com/products/{category}/{product}, but from the custom post type, the url I get is www.example.com/products/{product}.

When I registered the custom post type, I set rewrite to

'rewrite' => array('slug' => 'products', 'with_front' => false),

How can I fix this to include whatever category the post type is in?

0

You can try this :

'rewrite' => array('slug' => 'products/%category%'),
'query_var' => true /* etc */

But I think it won't work as is if other links do not follow the same structure. So maybe you'll find a way here.

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