WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

This question was marked as an exact duplicate of an existing question.

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

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