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', array( '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 :
register_taxonomy( 'book_category', 'book', array( '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 ?