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

<a href="https://wordpress.stackexchange.com/questions/71089/<?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); ?>

2 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 ); 

Leave a Reply

Your email address will not be published. Required fields are marked *