This is how you can loop with custom taxonomy.
function returnpost_tags(){
// get tags by post ID
$post_ID = get_the_ID();
// here, you can add any custom tag
$terms = get_the_terms( $post_ID , 'post_tag' );
echo '<ul>';
foreach ( $terms as $term ) {
// The $term is an object, so we don't need to specify the $taxonomy.
$term_link = get_term_link( $term );
$term_ID = $term->term_id;
// If there was an error, continue to the next term.
if ( is_wp_error( $term_link ) ) {
continue;
}
echo '<li><a href="' . esc_url( $term_link ) . '">' . $term->name . '</a></li>';
echo term_description($term_ID);
// another option
// echo '<p>' . $term->description . '</p>';
}
echo '</ul>';
}
add_shortcode('post-tags', 'returnpost_tags');
You can replace post_tag with your custom taxonomy
$terms = get_terms( 'post_tag' );
To get tag’s description, you can use one of the below method.
echo $term->description;
or
echo term_description($term->term_id);