I wanted to fetch the TAG Name with Tag ID, I tried it using get_tag() function but it doesn't print anything.
<?php
$certification = get_tag(13);
echo $certification->name; ?>
As I checked there is a Tag available in my wordpress with ID 13
can someone help to fix?
CodePudding user response:
$post_tags = get_the_tags($id); //your tagid
if ( $post_tags ) {
echo $post_tags[0]->name;
}
CodePudding user response:
You can try this code -
$tag_id = get_term_by('id', 13, 'post_tag');
echo $tag_id->name;
CodePudding user response:
You can use this code for getting the term name by id
$term = get_term( 13, 'post_tag' );
echo $term->name;
Hope it will work as I have tried it and working perfectly.