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.

Ok so at the moment I have a page which displays a list of categories within my Taxonomy (event-themes), here's the code:

<div id="themeSearch">
    <h1 class="mainSectionHeader">By Theme</h1>
    <ul id="themeSelector" class="jcarousel jcarousel-skin-tango">
        <?php
        //list custom portfolio categories
        $taxonomy = 'event-themes';  // define portfolio categories from taxonomies in functions.php
        $tax_terms = get_terms($taxonomy);

        foreach ($tax_terms as $tax_term) {
        echo '<li class="themeItem"><p><span>' . $tax_term->name.'</span></p><a href="index.php?<?php get_the_category( $id ) ?>" rel="' . $tax_term->slug . '"><span>Go</span></a>';
        }
        ?>
    </ul>
</div>

First of all, I am aware that the echo'd link does not work, and that is what I need help with.

I'm trying to not only display all of the categories, but I also want each of them to link to a page displaying the posts within that particular category.

I think I'm almost there with this code, as what I am trying to do is insert the category ID within the href so that for each listed category it directs to the correct page.

Many thanks

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

This should work:

foreach ($tax_terms as $tax_term) {
    echo '<a href="'.get_term_link($tax_term).'">'.$tax_term->name.'</a>';
}

Simplified a bit from your version for readability.

share|improve this answer
    
Very simple indeed! Thank you Joost –  remi90 Sep 28 '11 at 15: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.