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 switched my site from categories to taxonomies for my custom post but I am having trouble getting it to work the same way. For categories I could have templates named something like category-travel.php and then have my loop in that file. Now I am trying to replace the category list with something like this :

<?php  
$taxonomy = 'Gallery';
$orderby = 'name';
$show_count = 0;
$pad_counts = 0;
$hierarchical = 1;
$title = '';

$args = array (
    'taxonomy' => $taxonomy,
    'orderby' => $orderby,
    'show_count' => $show_count,
    'pad_counts' => $pad_counts,
    'hierarchical' => $hierarchical,
    'title_li' => $title
    );

wp_list_categories($args) ?>

and in functions

register_taxonomy( 'Gallery', array( 'photo' ), array( 'hierarchical' => true, 'label' => 'Galleries', 'singular_label' => 'Gallery', 'rewrite' => true ) );

Now when I link from that generated list, something like mysite.com/gallery/name it is instead calling the archive.php rather than the taxonomy-gallery.php file I created. What am I doing wrong?

Sorry if this is a duplicate but I think that question is for something different and I cant believe that you would have to do a hack for this.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

It looks like your issue is the name of your taxonomy has a capital letter, the first argument of register_taxonomy is to be all lowercase, no spaces as the documentation for the register_taxonomy function mentions here.

Change your code to the following and your taxonomy-gallery.php template will work correctly.

register_taxonomy( 'gallery', array( 'photo' ), array( 'hierarchical' => true, 'label' => 'Galleries', 'singular_label' => 'Gallery', 'rewrite' => true ) );

In the first bit of code you posted, you will also want to change the reference to the gallery taxonomy to be lowercase as well. Labels are fine with any case, but not actual names of taxonomies.

share|improve this answer
    
Ahh thanks! I had that page open one tab over but obviously did not read it very carefully. Appreciate the help! –  zac May 8 '12 at 3:43
    
No worries man. Simple things like that always happen to the best of us, I've been tricked up like that many times. –  DigitalSea May 8 '12 at 23:24
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.