WordPress

How to Show a List of Custom Taxonomy Terms in a WordPress Post

WordPress has offered custom taxonomy functionality for years, but it hasn’t taken center stage until WordPress 3.0 and the easy capability to create custom post types. Custom taxonomies are easy ways to create your own hierarchical terms (similar to post categories) or tags (similar to post tags).

Custom taxonomies don’t use the normal the_tags() functionality to display the terms (with a link to the appropriate archive page), instead, you need to use a different WordPress function to display custom freeform taxonomies.

How to Display a Custom Taxonomies on a Custom Post Page

In your custom post page template (e.g. single-shows.php), replace the_tags() with this code:

[php]<?php
echo get_the_term_list( $post->ID, ‘CUSTOM TAXONOMY NAME HERE’,
‘TEXT BEFORE’, ‘SEPARATOR’, ‘TEXT AFTER’ );
?>[/php]

For example, with a show-tags taxonomy, you could display a list using this command:

[php]<?php
echo get_the_term_list( $post->ID, ‘show-tags’,
”, ‘, ‘, ” );
?>[/php]

This will display a tag list, like this:

action, adventure, arnold, featured

You can use this for any type of taxonomies, including the built-in categories and tags taxonomies.

How to Display a Custom Taxonomy Tag Cloud

The standard tag cloud shows the normal tag taxonomy cloud. However, by using a simple function, you can display a tag cloud anywhere you would like:

[php]<?php
wp_tag_cloud( array( ‘taxonomy’ => ‘show-tags’,
‘number’ => 40 ) ); ?>[/php]

Custom taxonomies are an easy way to create unique categorization for your content. In this tutorial, you learned how to display those custom taxonomy terms that you create.