I've created a custom post type:

      'labels' => array(
         'name' => __("Campaigns"),
         'singular_name' => __("Campaign"),
      'rewrite' => array(
         'slug' => 'campaigns',
         'with_front' => FALSE,
      'public' => TRUE,
      'has_archive' => TRUE,
      'supports' => array('title', 'editor', 'thumbnail'),
      'publicly_queryable' => TRUE,

And a custom taxonomy for categories:

register_taxonomy( 'campaign_category', 'campaign', 
      'hierarchical' => TRUE, 
      'label' => 'Categories', 
      'query_var' => TRUE, 
      'rewrite' => array(
          'slug' => 'category',
          'with_front' => FALSE,
          'hierarchical' => FALSE,

Because the post type was created with has_achive set to TRUE I can browse to the /campaigns URL and my archive-campaign.php template is triggered. So far so good.

However, when I try to access a category, /campaigns/category/fashion, I get a 404.

The category with the correct slug exists and I've re-saved my permalinks each time I've made a chance to any of the rewriting rules.

Any suggestions would be much appreciated.

2 Answers 2


Two things:

  1. You shouldn't be using 'category' as a slug, since it's already built into WP and thus is reserved (http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms)

  2. Pretending for a moment that it isn't reserved, the base URL structure wouldn't contain the post type in front of it.


  1. I just realized you didn't set the archive slug itself. Instead of has_archive = true, set it to has_archive = 'campaigns' (to match your other slug). That should set your permalinks to match.
  • Thanks! 1. I don't think the reservered terms apply to the slug, however, I've tried with another slug (categoryx), re-saved my permalinks, no joy. 2. I do not understand what you mean. Can you explain it differently?
    – Luke
    Commented Dec 18, 2011 at 4:23
  • WordPress does not auto-create rules that bind post types with taxonomies, they create one set of rules for each. Does that help clarify?
    – t31os
    Commented Dec 18, 2011 at 13:39
  • 1
    adding to what @t31os said, your example setup would create: domain.com/campaign/post-slug domain/com/category/fashion/post-slug you would need to include some custom permalink re-writes. this post can give you a primer on it. shibashake.com/wordpress-theme/…
    – Norcross
    Commented Dec 18, 2011 at 15:16
  • @Norcross; Thanks for that link. I have a read through that. What you're saying is not entirely correct. I can happily browse to /campaigns/post-slug whereas /campaign/post-slug fails. Pagination on these archives are working fine, so why aren't categories? Would it be possible for you to update your answer and elaborate on 2. rather than adding comments?
    – Luke
    Commented Dec 18, 2011 at 21:01
  • @Norcross; Thanks heaps! Your EDIT put me on the right track. I do not have to create a dummy page anymore for '/campaigns' and all templates are working correctly now!
    – Luke
    Commented Dec 19, 2011 at 23:57

You have to se up your taxonomy slug as "%campaign_category%" and replace it in a function later.

Here I explain how I did it (I applied it to the category itself because I wanted to also delete the category slug from the url, but will understand)

Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?

Let me know if your different case breaks the other links too. This solutions worked for others but I think it breaks in my site because some other reasons, e.g. multisite installation.

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.