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've created a custom post type called 'work' for a portfolio section on the site I am working on at the moment. I have also registered the taxonomy 'workcategories' so that I can assign different pieces of work to different categories like:

Artists, Charities, Independents, International, Well Known

Which I have created via the WordPress Admin.

My problem is that I can't figure out how to display these terms as a list of links within my sidebar under the title 'Categories' and for these terms to link to archive pages displaying the work assigned to each.

At the moment I have this code in my index-work.php page to display ALL WORK:

<?php query_posts('post_type=work&posts_per_page=4'); ?>

And I think I need to adapt this for my taxonomy pages. I've created a taxonomy-workcategories.php page for this purpose, but not sure if I actually have to create a separate page for each term listed above? Or can I use the taxonomy-workcategories.php all.

Any help much appreciated as I'm a bit lost. It's my first time working with taxonomies and I'm finding it all a bit confusing.

share|improve this question

1 Answer 1

You shouldn't have to create a separate template file for each taxonomy.

You can use the wp_list_categories function to create a list in your sidebar, the Codex article has a code example, but something like this should work:

<ul>
    <?php wp_list_categories('taxonomy=workcategories'); ?>
</ul> 
share|improve this answer
    
I used the code from the Codex article and this works perfectly for listing my categories. thanks. –  Evie Milo Oct 19 '11 at 10:33
    
I also created a seperate template file for each taxonomy as it wouldn't work otherwise –  Evie Milo Oct 19 '11 at 10:58

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.