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?

1 Answer 1


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.

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.