Home Forums Themes Support How to display the term of custom taxonomy WordPress

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #11955

    Hi all customer,

    In this topic tutorial, we’ll help you display term of custom taxonomy in WordPress.

    Reference about custom taxonomy for custom post type here: https://developer.wordpress.org/plugins/taxonomies/working-with-custom-taxonomies/

    To display a list of custom taxonomy you can use this code:

    <?php echo get_the_term_list( $post->ID, $taxonomy->name, ”, ‘, ‘ ); ?>

    Example: you can change $post->ID to get_the_ID() and $taxonomy->name to video_category (your taxonomy name)

    or use another solution:

    <?php
    foreach( $terms as $key => $term ) {
    if ( end($terms) == $key ) {
    echo ‘<a href=”‘ . get_term_link( $term->term_id ) . ‘”>’ . $term->name . ‘</a>’;
    } else {
    echo ‘<a href=”‘ . get_term_link( $term->term_id ) . ‘”>’ . $term->name . ‘</a>, ‘;
    }
    }
    ?>

    Hope this helps!

    ****
    Regards,

    HaruTheme

    • This topic was modified 1 month, 1 week ago by admin.
    • This topic was modified 1 month, 1 week ago by admin.
    • This topic was modified 1 month, 1 week ago by admin.
    • This topic was modified 1 month, 1 week ago by admin.
    • This topic was modified 1 month, 1 week ago by admin.
    • This topic was modified 1 month, 1 week ago by admin.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.