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

I've made a custom post type book and a custom taxonomy book_category. I've been trying to create an archive page where the books belonging to a particular category can be viewed. So far I've only been able to get an archive page of all the books by creating an archive-book.php file to customize the view. What should be the next step from here ?

My preferred url should be of the form: mysite.com/books/[slug of book_category]

My understanding is that some kind of URL rewrite rule has to be in place, but I'm not sure how to do that. Any help would appreciated, thanks.

The custom post type was registered in the following way:

register_post_type( 'book',
        'labels' => array(
            'name' => __( 'Books' ),
            'singular_name' => __( 'Book' ),
            'menu_name' => __('Books'),
            'all_items' => __('All books')
    'public' => true,
    'has_archive' => true,
    'taxonomies' => array('book_category', 'book_author'),
    'supports' => array( 'title', 'comments', 'excerpt', 'custom-fields', 'thumbnail', 'editor' ),
    'rewrite' => true,

To register the custom taxonomy :

        'label' => __( 'Book Categries' ),
        'labels' => array(
            'name' => 'Book Categries',
            'singular_name' => 'Book Categry',
        'public' => true,
        'show_ui' => true,
        'rewrite' => array( 'slug' => 'book_category' ),
        'capabilities' => array(
            'assign_terms' => 'edit_guides',
            'edit_terms' => 'publish_guides'
        'meta_box_cb' => 'show_book_category_ui'


I managed to make the url change by following Milo's advice. But the taxonomy-book_category.php then becomes useless. Trying to rename it to taxonomy-books.php did not work. What should be the name of this file now ?

share|improve this question

To achieve the URL mysite.com/books/[slug of book_category], in your taxonomy registration code, change:

'rewrite' => array( 'slug' => 'book_category' )


'rewrite' => array( 'slug' => 'books' )
share|improve this answer
Hi Milo, I managed to change the URL by following your advice. But now the taxonomy-book_category.php is not being used anymore. I tried to rename it to taxonomy-books.php, that did not work either. What should I do now ? – Raiyan Jan 22 '14 at 7:22

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.