Get terms form specific taxonomy

Suppose, you want to get a list of your all category as name or you want to get a list of your custom taxonomy. Here is how you can foreach that.

// Storing taxonomy's ID in a variable. 
$terms = get_terms( 'product_cat' );

// Retrieve list as name
echo '<ul>';
foreach ( $terms as $term )  { 
    echo '<li>' . $term->name . '</li>';
}
echo '</ul>';

WordPress.com Codex

Leave a Reply

Your email address will not be published. Required fields are marked *