Using this snippet you can get your taxonomy’s terms and show them as a list or <a> link

/**
 * Snippet Name: Display custom taxonomy like the category for custom post type
 * Snippet URL: https://css-tricks.com/forums/topic/display-custom-taxonomy-like-the_category-for-custom-post-type/
 */
$terms = get_the_terms( $post->ID , 'YOUR_CUSTOM_TAXONOMY' );
foreach ( $terms as $term ) {
    $term_link = get_term_link( $term, 'YOUR_CUSTOM_TAXONOMY' );
    if( is_wp_error( $term_link ) )
    continue;
    echo '<a href="' . $term_link . '">' . $term->name . '</a>';
}

This is my adapted version for my wesbite

/** Snippet Name: Display custom taxonomy like the category for custom post type
 * Snippet URL: https://giangle.dev/snippet/display-custom-taxonomy-like-the-category-for-custom-post-type/
 */
$terms = get_the_terms( $post->ID , 'snippet_cat' );
$i = 0;
foreach ( $terms as $term ) {
    $term_link = get_term_link( $term, 'snippet_cat' );
    if( is_wp_error( $term_link ) )
    continue;
    if ( $i <= 1 ) {//get 2 terms only
    echo '<a href="' . $term_link . '"><span><i class="far fa-bookmark"></i>'. $term->name .'</span></a>';
    }
    $i++;
}

You will get something like this

How to Get WordPress custom taxonomy's terms

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x