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); ?> <ul> <?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; ?> </ul>
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!
- The topic ‘Listing out terms for a taxonomy?’ is closed to new replies.