get a specific taxonomy term name

by federica   Last Updated April 09, 2018 17:08 PM

I need to print a specific term with its id. I get that for categories with this code:

<a href="<?php echo get_category_link(1); ?>" title="<?php echo get_cat_name(1);?>"><?php echo get_cat_name(1);?></a>

… where 1 is the id I have to print. Is there something like the following?

<?php echo get_term_link(1); ?>


<?php echo get_term_name(1); ?>
Tags : taxonomy terms

Answers 2

Use get_term() to get the name, slug, or description:

$term = get_term( 1, 'taxonomy_slug' );
// Name
echo $term->name;

// Link
echo get_term_link(1, 'taxonomy_slug'); 
// OR
echo get_term_link( $term ); 
Eric Holmes
Eric Holmes
October 31, 2012 17:00 PM

Since WP 2.3.0, there is an API to get term's fields : get_term_field().

So, I would rather use <?php get_term_field( 'key', $term ); ?> which is pretty handy :

  • key : could be multiple : link, name, etc.
  • $term : can either be the term_id or the \WP_Term object.
Maxime Culea
Maxime Culea
April 09, 2018 16:54 PM

Related Questions

Why does wp_remove_object_terms not work?

Updated April 01, 2018 06:08 AM

Get terms in hierarchical taxonomy

Updated April 10, 2017 19:08 PM