How do I print all the items in a particular taxonomy?

Tips and tricks from Tamara Olson Designs

Simple. get_terms:

<?php
$terms = get_terms( 'primary-subject' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
echo '<li class="term-menu" id="' . $term->slug . '">' . $term->name . '</li>';
}
}
?>

 


Share Your Thoughts

About the Author

TamaraAuthorPhoto

Tamara Olson is a self-employed UX designer and WordPress developer living in New York City.

Tamara Olson Designs Case Studies