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); ?>
or
<?php echo get_term_name(1); ?>
Use
get_term()
to get the name, slug, or description: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.