Get and Display Custom Taxonomies function

The new WordPress Custom Post types are awesome, and if you do want to categorize them differently, you can even add your own Taxonomies for them (like categories, tags, and even introduce your own names, like “colors”, “style”, etc. etc.). All seem unlimited, but I found myself struggling finding a way to reasonably display them afterwards.
Hope this function helps, if you ever find yourself in my position

function get_taxonomy_display($taxonomy_name) {
return strip_tags( get_the_term_list( $wp_query->post->ID, '$taxonomy_name', '', ', ', '' ) );
}
$custom_categories = get_taxonomy_display('enter_your_taxonomy_name');
echo $custom_categories

4 comments

  1. You forgot rule number one in WordPress function creation: avoid too generic function names, like my_function(), get_taxonomy_name(), …
    add some prefix,suffix – themerme_my_function(), themerme_get_taxonomy_display(), …

    😉 Keep posting, interesting!

Leave a Reply

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