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 have a loop of posts for a custom post type I built.

How can i call the link of the category/taxonomy for each post?

Thanks

share|improve this question
add comment

1 Answer 1

Use get_term_link(); for example:

$terms = wp_get_post_terms( $post->ID, 'category');
echo '<ul>';
foreach ($terms as $term) {
    echo '<li><a href="'.get_term_link($term->slug, 'category').'">'.$term->name.'</a></li>';
}
echo '</ul>';
share|improve this answer
    
what if i have 2 categories assigned @Bainternet ?.. can i stop the foreach after one time ? –  Sagive SEO Mar 16 '12 at 20:17
    
Yeah you can, ask that as a new question and I'll show you.\ –  Bainternet Mar 16 '12 at 22:59
    
thanks man :) got lucky and found a good explenation - thanks anyhow and have a gr8 weekend –  Sagive SEO Mar 17 '12 at 4:27
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.