I have my custom post type with the slug /news. And I want my category view to be /news/category/CATEGORYID.

For that I create my custom taxonomy:

add_action('init', 'create_allfilmnews_categories', 0);
function create_allfilmnews_categories() {
    $labels = array(
        'name' => _x( 'Categories', 'taxonomy general name' ),
        'singular_name' => _x( 'Category', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search categories' ),
        'all_items' => __( 'All category' ),
        'parent_item' => __( 'Parent category' ),
        'parent_item_colon' => __( 'Parent category:' ),
        'edit_item' => __( 'Edit category' ),
        'update_item' => __( 'Update category' ),
        'add_new_item' => __( 'Add new category' ),
        'new_item_name' => __( 'New category name' ),
        'menu_name' => __( 'News categories' ),

    register_taxonomy('news_category', 'news', array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'category' ),

I was hoping, that since it is hooked to news custom post-type.. and its slug is "category", so I was hoping that naturally it would work out like I wanted (/news/category/CATEGORYID). And use my custom category-template just by creating a file to the template directory: category-news_category.php.

However, of course it is not working.

Is it even possible to have a custom taxonomy aka. categories inside custom post-type, that work perfectly with permalinks?

1 Answer 1


Two things - I think the category URL would be: yourdomain.com/news_category/NEWS-CATEGORY-SLUG-HERE

So for example if you created a category "top headlines" in your "news_category" taxonomy... it would look like this (assuming the slug for "top headlines" is "top-headlines"):


The second thing... I think your template name should be "taxonomy-news_category.php"

(edited to add - I don't think you can have the slug be "category" as that is being used by WordPress already.. so that may be causing a conflict in itself...I could be wrong on that though...)

  • Your right on the money! I actually got this EXACTLY the same method working last night. My overall solution was, that the custom taxonomy slug was simply: "news/category" and indeed the template-name for custom taxonomy would be taxonomy-news_category.php Works 100% like I wanted. Dec 9, 2011 at 15:33

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.