How to display custom taxonomies in posts?

Almost all themes display categories (with its permalink) by default. I am looking for similar type of code to add in my theme. From where can I get it?
To create custom taxonomies, I’m using More Taxonomies plugin.

Related posts

Leave a Reply

3 comments

  1. The easiest way to list terms of custom taxonomy and display them would be to use

     <?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?> 
    

    For example in the loop, my custom taxonomy is ‘jobs’ list as li

     <ul><?php echo get_the_term_list( $post->ID, 'jobs', '<li class="jobs_item">', ', ', '</li>' ) ?></ul>
    
  2. Check this out. it worked for me. i have a taxonomy named ‘stores’, and i wanted to display 2 taxonmies from it.

    <?php
        $taxonomy = 'stores';
        $args1=array(
            'include'=> array(12,30)
            );
    
        $terms = get_terms('stores',$args1 );
        echo '<ul>';
    
    
        foreach ($terms as $term) {
            //Always check if it's an error before continuing. get_term_link() can be finicky sometimes
            $term_link = get_term_link( $term, 'stores' );
            if( is_wp_error( $term_link ) )
                continue;
            //We successfully got a link. Print it out.
    
    
            echo '<li><a href="' . $term_link . '">' . $term->name . '</a></li>';
        }
        echo '</ul>';
        ?>