Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This question already has an answer here:

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?

share|improve this question
add comment

marked as duplicate by Bainternet May 24 '13 at 0:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

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.

share|improve this answer
add comment

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