How To Get All Taxonomies For a Post Type


Here is a useful code snippet to retrieve the terms in taxonomy or list of taxonomies for a custom post type.

[php]
$terms = get_terms( ‘projects’ );
$count = count( $terms );
if ( $count > 0 ) {
echo ‘<h3>Total Projects: ‘. $count . ‘</h3>’;
echo ‘<ul>’;
foreach ( $terms as $term ) {
echo ‘<li>’ . $term->name . ‘</li>’;
}
echo ‘</ul>’;
}
[/php]

This code snippet will retrieve all terms of projects taxonomy from a custom post type.

Reference:

You may also be interested to learn Exclude Multiple Categories From Loop.


Comments

Leave a Reply

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