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.

I have created a custom post type with custom taxonomies. Now I need help with the permalinks.

Now is like that:

  • custom post type archive: example.com/custom-post-type/
  • taxonomy archive: example.com/taxonomy/
  • single custom post type: example.com/custom-post-type/single/

It should be like that:

  • custom post type archive: example.com/custom-post-type/
  • taxonomy archive example.com/custom-post-type/taxonomy/
  • single custom post type: example.com/custom-post-type/taxonomy/single/

How can I achieve that?

share|improve this question
    
for single custom post type, do you mean /cpt/term/single/, or do you want the name of the taxonomy there? –  Brian Fegter Aug 30 '12 at 16:48
    
That's right. The URL will be /CPT/TERM/SINGLE/ –  rodboc Aug 30 '12 at 17:21
    
Are you using just one taxonomy? –  Brian Fegter Aug 30 '12 at 17:23
    
No, there'll web seven or eight taxonomies. –  rodboc Aug 30 '12 at 19:06

1 Answer 1

up vote 0 down vote accepted

Plugin Recommendation

I've had some great experience with the plugin Custom Post Type Permalinks.

Here's the settings panel that it provides which allows you to define your structure per custom post type.

Custom Post Type Permalinks Admin

Adding More Permalink Tags

If you want to further extend the permalink structure tags for your needs you can take a look at the add_rewrite_tag API function.

CTP Tax Archive

The CPT Permalinks plugin won't take care of your CPT Tax archive, so you need to add the following rewrite rule to your functions.php file:

add_rewrite_rule('^(your-cpt)/(taxonomy_1|taxonomy_1|taxonomy_3)/?','index.php?post_type=$matches[1]&taxonomy=$matches[2]','top');

You will obviously need to replace your-cpt and the taxonomy names in the regex.

Testing

I highly recommend you to use the Monkeyman Rewrite Analyzer to help understand what rewrites are registered and how they match your URLs.

Hope this helps you out.

share|improve this answer
    
Thank you for the help :) –  rodboc Sep 3 '12 at 21:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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