I think that when you define custom rewrite slugs in the registration of a custom taxonomy, you still need to add custom rewrite rules.
add_action('init','my_add_rewrite_rules');
function my_add_rewrite_rules() {
add_rewrite_rule( 'rights/category/(.+)/page/([0-9]{1,})/?$', 'index.php?post_type=rights&category=$matches[1]&paged=$matches[2]', 'top' );
add_rewrite_rule( 'rights/category/(.+)/?$' , 'index.php?post_type=rights&category=$matches[1]' , 'top' );
}
In order to add the correct rewrite rule I would need the code of the custom post type and custom taxonomy registration. Also, don’t forget to flush rewrite rules by visiting WP admin area->settings->permalinks.
I can confirm from my own tests that @G.M. is correct (see first comment to the question). If you register your cpt with the singular name right
and set the has_archive
argument to the plurgal slug rights
, the custom rewrite
argument in register_taxonomy
you are using will work without any custom rewrite rules. So you can register the cpt with register_post_type('right', $args)
where $args['has_archive'] = 'rights'
. But now you will have:
- domain.com/rights/ -> for archive view
- domain.com/right/a-custom-post/ -> for single custom post view
- domain.com/rights/taxonomy-slug/term-slug/ -> the term archive view
So, I still prefer register the cutom post type with plural slug and add the rewrite rules in order to have a more consistent permalink structure like this (all urls will inclue ‘rights’ slug):
- domain.com/rights/ -> for archive view
- domain.com/rights/a-custom-post/ -> for single custom post view
- domain.com/rights/taxonomy-slug/term-slug/ -> the term archive view