1

I've spend the better part of a day trying to figure this out. My custom taxonomy shows up in the WordPress admin, I can add it to a nav and display it with wp_nav_menu, but when I click on any of the terms I get a 404 even though I have a taxonomy.php in the theme. Any ideas?

/** Product custom post type **/
add_action( 'init', 'product_post_type' );
function product_post_type() {
  register_post_type( 'product',
    array(
      'labels' => array(
        'name' => __( 'Products' ),
        'singular_name' => __( 'Product' ),
        'add_new_item' => __( 'Add New Product' ),
        'new_item' => __('New Product'),
        'all_items' => __( 'All Products' ),
        'view_item' => __('View Products' ),
        'search_items' => __('Search Products'),
        'not_found' =>  __('No Products found'),
        'not_found_in_trash' => __('No Products found in Trash'), 
        'parent_item_colon' => '',
        'menu_name' => __('Products')
      ),
    'menu_position' => 5,
    'public' => true,
    'taxonomies' => array('product')
    )
  );
}

/** product Taxonomy **/

add_action( 'init', 'create_product_taxonomy' );

function create_product_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 Product Category' ),
    'new_item_name' => __( 'New Product Category' ),
    'menu_name' => __( 'Product Categories' ),
  );    

  register_taxonomy('product', array('product'), array(
    'public' => true,
    'hierarchical' => true,
    'labels' => $labels,
    'query_var' => true
  ));
}
6
  • is this an online site you are adding new taxonomy to? if so you should deactivate the theme then reactivate it
    – Sagive
    Jul 25, 2012 at 20:14
  • I've tried activating and deactivating. I've also re-saved my permalinks.
    – Ian Hoar
    Jul 25, 2012 at 20:26
  • The other strange thing is, categories work in other themes. Within this theme even the default posts categories do not work. I'm trying to figure out what I have done to break them.
    – Ian Hoar
    Jul 25, 2012 at 20:29
  • have you created a product-page.php page?
    – Sagive
    Jul 26, 2012 at 11:57
  • It seems to be being caused by the custom post type of product. If I remove it the taxonomy.php works. I don't understand this, because I created the product post type so I had a place to add the taxonomies.
    – Ian Hoar
    Jul 26, 2012 at 16:25

1 Answer 1

3

Okay, I feel quite silly, but what it comes down to is you can't have a custom post type and custom taxonomy with the same name. (Well... you can, but your taxonomy templates won't work) In my case I changed my content type to "product" and my taxonomy to "products". This fixes everything along with a permalink refresh.

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.