Support » Alpha/Beta/RC » Listing out terms for a taxonomy?

  • I’m wondering what the best way to put a simple list of terms as links for a particular taxonomy is into your theme? Similar to how wp_list_pages() would list out pages or wp_list_categories() would list out categories?

    For example, maybe you have some custom post type of “products” and you have those organized in a custom taxonomy of “catalogs.” What’s the best way to list out links to all of the different “catalogs”?

    This is the only way I’ve figured out how to do it:

    <?php $term_obj =  get_terms($taxonomy,$args); ?>
    	<?php foreach ($term_obj as $term) : ?>
    	<li><a href="<?php echo get_term_link($term->slug,$taxonomy); ?>"><?php echo $term->name; ?></a></li>
    	<?php endforeach; ?>

    Seems like this would be a popular thing to do and that’s why my gut feeling is that the above method is more complicated than it needs to be. Anyone know anything about this? Thanks in advance!

Viewing 1 replies (of 1 total)
  • Chris Olbekson


    Level 12 Bug Squasher & Forum Moderator

    Here is what I am using to list out the terms for a custom taxonomy that contains custom posts:

    <?php query_posts( array( 'Recordings' => 'live' ) ); ?>
    <?php if( is_tax() ) {
        global $wp_query;
        $term = $wp_query->get_queried_object();
        $title = $term->name;
    }  ?>
    <span class="tax-title"><?php echo($title); ?></span>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
    <?php endwhile; else: ?>
    <?php endif; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Listing out terms for a taxonomy?’ is closed to new replies.