Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a CPT called "books", a custom taxonomy called "book" for this CPT, and a "taxonomy-books.php" template in which I display my "books" terms using get_terms(). I don't understand (yes, I googled the problem) how to visit the page attached to this template. For one, "www.my_site.com/books/" doesn't work (page not found). Here's how I defined my custon taxonomy:

$labels = array(
    'name'                          => 'Books',
    'singular_name'                 => 'Book',
    'search_items'                  => 'Search Books',
    'popular_items'                 => 'Popular Books',
    'all_items'                     => 'All Books',
    'parent_item'                   => 'Parent Book',
    'edit_item'                     => 'Edit Book',
    'update_item'                   => 'Update Book',
    'add_new_item'                  => 'Add New Book',
    'new_item_name'                 => 'New Book',
    'separate_items_with_commas'    => 'Separate Books with commas',
    'add_or_remove_items'           => 'Add or remove Books',
    'choose_from_most_used'         => 'Choose from most used Books'
    );

$args = array(
    'label'                         => 'Books',
    'labels'                        => $labels,
    'public'                        => true,
    'hierarchical'                  => true,
    'show_ui'                       => true,
    'show_in_nav_menus'             => true,
    'args'                          => array( 'orderby' => 'term_order' ),
    'rewrite'                       => array( 'slug' => 'books', 'with_front' => false ),
    'query_var'                     => true
);

register_taxonomy( 'books', 'book', $args );

So articles online made me think that the "rewrite" line was in cause, I removed it and it's the same.

share|improve this question
1  
www.my_site.com/books/ - this is the prefix for your taxonomy, and it should return a 404 logically. As like www.my_site.com/category/ will do the same. What you are missing is the term slug. Create at lease one term, the try vising www.my_site.com/books/term_slug/ and it should display a valid page. And moreover, Terms page itself is an archive of the object, and it doesn't or won't have archive of itself. What you can do is create a WordPress Page with slug books and then rename taxonomy-books.php file to page-books.php. It should work then –  Shazzad Jan 19 at 15:51
1  
taxonomy-books.php file is responsible to handle request for www.my_site.com/books/(*)/ location –  Shazzad Jan 19 at 15:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.