2

I don't quite understand how to link to my taxonomy templates. Do I need to make a page-tempalte and query my terms from there? I'm using the taxonomy hierarchy currently:

Taxonomy

$labels = array(
        'name'              => __( 'Product Categories' ),
        'singular_name'     => __( 'Product Category' ),
        'search_items'      => __( 'Search Product Categories' ),
        'all_items'         => __( 'All Product Categories' ),
        'parent_item'       => __( 'Parent Product Category' ),
        'parent_item_colon' => __( 'Parent Product Category:' ),
        'edit_item'         => __( 'Edit Product Category' ), 
        'update_item'       => __( 'Update Product Category' ),
        'add_new_item'      => __( 'Add New Product Category' ),
        'new_item_name'     => __( 'New Product Category' ),
        'menu_name'         => __( 'Product Categories' ),
    ); 
    $args = array(
        'labels'            => $labels,
        'show_in_nav_menus' =>  false,
        'hierarchical'      => true,
        'rewrite'           =>  array('slug' => '/products', 'with_front' => false),
    );
    register_taxonomy( 'protax', 'product', $args );

Then I have a taxonomy template : taxonomy-protax.php which I should be able to get to via www.mywebsite.com/products but it keeps leading to 404. Taxonomy template always seem to give me the most trouble... How do I view my taxonomy-protax.php page?

1
  • "which I should be able to get to via www.mywebsite.com/products" No. You should be able to get a term archive with www.mywebsite.com/products/a-term, WordPress has no taxonomy archive, but term archives.
    – gmazzap
    Commented Sep 23, 2013 at 16:12

1 Answer 1

1

According to the Codex:

taxonomy-{taxonomy}.php - If the taxonomy were sometax, WordPress would look for taxonomy-sometax.php

What I do when using custom taxonomy/custom post types is exactly what you mentioned in the second sentence. Make a page template and a page in the back end. Choose the template you built as the template to use when making your page.

Template Selector

EDIT

Just noticed that you're getting a 404. In that case, check your permalink structure as well.

Again, from the Codex:

If your site uses custom permalinks, you will need to flush your permalink structure after making changes to your taxonomies, or else you may see a "Page Not Found" error. Your permalink structure is automatically flushed when you visit Settings > Permalinks in your WordPress dashboard.

1
  • Right, I guess just because I have taxonomy doesn't mean WP will automatically create a url based on it, I would infact have to create a page for it. I guess it's not a huge deal but kind of inconvenient.
    – Howdy_McGee
    Commented Sep 23, 2013 at 16:15

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.