0

I've registered a couple of custom taxonomies to go with a couple of custom post types but I'm having some trouble getting a template file to work.

I've tried taxonomy.php, taxonomy-[termname].php, taxonomy-[taxonomyname].php but none seem to register and the link reverts to index.php

You can see an example of this here - http://wordman.deanelliott.me/portfolio/ just click on any of the links inside the yellow box and instead of going to a specific taxonomy template page it uses index.php

I'm not sure if it makes a difference, but this is the code I'm using to register the taxonomy

register_taxonomy('cat', 'portfolio',  array('hierarchical' => false, 'label' => 'Category','query_var'  => true, 'rewrite' => true));

2 Answers 2

0

I think this is because you use a reserved name: http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

Try changing in to something else like:

register_taxonomy('portfolio_category', 'portfolio',  array('hierarchical' => false, 'label' => 'Category','query_var'  => true, 'rewrite' => true));
3
  • That stopped index.php from being used, but it still doesn't seem to want to use any of the taxonomy template files I created (It doesn't seem to use any, all I get is the header and footer, no content) Commented Dec 20, 2011 at 23:51
  • Are you sure the taxonomy.php template has some code in it (besides get_header and get_footer)? Here you can see the template hierarchy: codex.wordpress.org/images/1/18/Template_Hierarchy.png It has to be one of those templates under custom taxonomy archive. And don't forget to flush your permalink rewrite rules (go to permalinks under settings and thats done). Commented Dec 20, 2011 at 23:56
  • I just went back to the test site to do this and it appears to be working now. Maybe it was just the browser cache playing tricks on me. Thanks for your help anyway Commented Dec 21, 2011 at 10:13
0

I think you need to have the 'portfolio' inside an array like this:

<?php
register_taxonomy( 'cat', array( 'portfolio' ),  
  array(
    'hierarchical' => false, 
    'label' => 'Category',
    'query_var'  => true, 
    'rewrite' => true)
  );
?>

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.