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?


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>';
  • what if i have 2 categories assigned @Bainternet ?.. can i stop the foreach after one time ?
    – Sagive
    Mar 16, 2012 at 20:17
  • Yeah you can, ask that as a new question and I'll show you.\
    – Bainternet
    Mar 16, 2012 at 22:59
  • thanks man :) got lucky and found a good explenation - thanks anyhow and have a gr8 weekend
    – Sagive
    Mar 17, 2012 at 4:27

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.