WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

We have a custom type music.


Also, we have a tag-like taxonomy genres. Its urls are:


I'm trying to make urls like:


/music-genres/ should be replaced by /music/genres/.

Finally we should get url structure like:


How do I do this?

share|improve this question
Possible duplicate of wordpress.stackexchange.com/questions/12843/… – Bainternet Mar 31 '11 at 11:40
@Bainternet its not a duplicate – ilovewordpress Mar 31 '11 at 13:46
@ilovewordpress: care to explain better then, what's the difference? Maybe i can help. – Bainternet Mar 31 '11 at 14:11
@Bainternet I have edited the topic. – ilovewordpress Mar 31 '11 at 15:50
It looks the same to me. ilovewordpress, you should take a look at Jan Fabry's answer on wordpress.stackexchange.com/questions/12843/… I think it would help you. – gabrielk Mar 31 '11 at 18:38
up vote 3 down vote accepted

Yes, this is possible, because your genres structure is /music/genres/[genre-name]. If it was /music/[genre-name] it would be complicated because it would conflict with /music/[post-name].

You just have to keep the order in mind. The rewrite rules should be ordered from most specific to least specific. If you first register the post type and then the taxonomy, the post type rules will come first. The problem is that the post type rules contain a very generic rule to match attachments, and this would mess with our taxonomy terms. But it will work if you first register the taxonomy and then the post type.

The confusing thing is that you normally pass the post types that will use the taxonomy you are registering, but you can just pass the empty array and make the connection later.

add_action( 'init', 'wpse13608_init' );
function wpse13608_init()
            'rewrite' => array(
                'slug' => 'music/genre'
    register_post_type( 'music' );
    register_taxonomy_for_object_type( 'music-genre', 'music' );

You can verify this and play with your rules with my Rewrite analyzer plugin.

share|improve this answer

Maybe you can find some information on this post: Custom post types, taxonomies, and permalinks.

share|improve this answer
its not clear for me, can you please explain better? – ilovewordpress Apr 2 '11 at 15:51

WordPress does not support overloading permalink structures to the degree you want. You can write your own pre-rewrite filter to convert your desired URLs into URLs that WP_Rewrite can recognize, and then write filters to convert WordPress-generated links into your own style.

To understand this, study WP_Rewrite::generate_rewrite_rules and WP::parse_request, which are commonly regarded as "voodoo".

share|improve this answer
I'm a newbie in wordpress, please give a coded example. I've tryed something, had no luck. – ilovewordpress Apr 6 '11 at 23:28

Your Answer


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.