I have been digging the code for days and no solution. :( I have a Custom Post Type and two different Taxonomies.

It is possible to achieve the following permalink structure (with add_rewrite_rule, mod_rewrite or post_type_link post type filter) or not?


not required, but would be nice to create these URLs too

mysite.com/post-type-slug/taxonomy1-term/taxonomy1-subterm - if each tax. is hierarchical
mysite.com/post-type-slug/taxonomy-term1/post1 - display posts under tax. URLs

Do you have any idea?

1 Answer 1


I'll look into the last two soon but for the top 3 you could do the following:


This defaults to the post type name you specify when registering it but can be altered by changing the rewrite argument in the register_post_type() call.

register_post_type( 'posttype', array(
    // ... all the other args...
    'rewrite' => array( 'slug' => 'post-type-slug' ),
    // if you want to list a post type with no taxonomy involvement
    'has_archive' => 'post-type-slug'
) );


I don't think you can easily get the hyphen between the taxonomy name and the term name if that's what you mean but you can do the following:

register_taxonomy( 'taxonomy1', 'posttype', array(
    // ... all the other args...
    'rewrite' => array( 'slug' => 'post-type-slug/taxonomy-slug' )
) );

Which will give you a URL like this:


I wasn't too sure from your question but if you don't want the taxonomy-slug to be there then you're out of luck, you can't have the same slug as your post type or another taxonomy as it won't know what term is from which taxonomy and what's a post.

To get the heirarchical terms URL do this:

register_taxonomy( 'taxonomy1', 'posttype', array(
    // ... all the other args...
    'rewrite' => array( 'slug' => 'post-type-slug/taxonomy-slug', 'heirarchical' => true )
) );

Which gives you



If it helps setting slug to false gets rid of it altogether so you'd get:


  • Thank you for your answer. The following structure what you mentioned is good for me: mysite.com/post-type-slug/taxonomy-slug/term A quite strange thing happened. :) This solution only works with hierarchical taxonomies. more accurately only taxonomy-sub-term URLs work. mysite.com/post-type-slug/taxonomy1-slug/taxonomy1-term/taxonomy1-subterm - works mysite.com/post-type-slug/taxonomy1-slug/taxonomy1-term - doesn't work (404)
    – Attila
    Commented Nov 3, 2011 at 19:37
  • @user9909 is that with 'hierarchical' => true in the rewrite argument of register taxonomy? You may have to flush the permalinks first by going to permalinks in the admin and clicking save changes. Commented Nov 4, 2011 at 9:46
  • I changed the order of Taxonomies and CPTs. It works. Great. :D
    – Attila
    Commented Nov 4, 2011 at 9:51
  • Ah cool. Glad I could help. Unfortunately the more advanced single post page URLs are a lot trickier to do. I'll post here anyway if I get a chance to figure it out. Commented Nov 4, 2011 at 10:04
  • Thnak you. I tried to manage with a post_type_link filter, but couldn't. It's enough for me, that would be onlye a plus. :)
    – Attila
    Commented Nov 5, 2011 at 8:58

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.