WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom post type, I am echoing out my custom taxonomies in my template by doing the following, get_the_term_list( get_the_ID(), 'work', '<li>', "", '</li>') , this currently returns "Design", what I am wanting to do, is the following, for the first value that it is found I want to do the following,

<li><a href="the taxonomies link"> Find out more about Taxonomy Name</a></li>

for the second value (if there is a 2nd) I would like the do the following

<li><a href="the taxonomies link">How Taxonomy Name can benefit you</a></li>

Basically how ever many taxonomies there I only want to show 2 and I want to be able to use them as above? Is this even possible?

share|improve this question
up vote 0 down vote accepted

I would use wp_get_object_terms which will return an array of object terms that you can manipulate. You also have a little more control with sorting the terms.

$terms = wp_get_object_terms($post->ID, 'work', array('orderby' => 'name', 'order' => 'ASC'));
if(is_array($terms)) : ?>
    <?php if(isset($terms[0])) : ?><li><a href="<?php echo get_term_link($terms[0]); ?>">Find out more about <?php echo $terms[0]->name; ?></a></li><?php endif; ?>
    <?php if(isset($terms[1])) : ?><li><a href="<?php echo get_term_link($terms[1]); ?>">How  <?php echo $terms[1]->name; ?> can benefit you</a></li><?php endif; ?>
<?php endif; ?>

Obviously, this is not a very dynamic solution and will only work for your first two terms, but these functions should help you sort out the correct solution for you.

share|improve this answer

Your Answer


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.