Tag list & tag index for custom post type

There is a WordPress function called get_terms. This will provide you with the output of your custom taxonomy throughout your website.

I’ve also included insight as to how to use WordPress’s native tag support when you register your custom post type and custom templates for taxonomies.

If you wish to retrieve all instances of your custom taxonomy and format a list, you can use get_the_term_list and use your custom taxonomy as parameter 2 of the function.

<?php get_the_term_list( $id, $taxonomy, $before, $sep, $after ) ?> 

If you wish to retrieve the instances of your custom taxonomy on a per post basis, use wp_get_post_terms and use your custom taxonomy as parameter 2 of the function.

<?php $terms = wp_get_post_terms( $post_id, $taxonomy, $args ) ?>

When creating a custom post type, you can set the argument ‘taxonomies’ to utilize WordPress’s native post tag functionality.

'taxonomies' => array('category', 'tags', 'custom-taxonomy'),

This would then enable you to utilize the functions offered for tags such as the_tags or wp_tag_cloud

You should also consider a taxonomy.php because WordPress defaults the display of any taxonomy from taxonomy.php. This would also allow you customize the appearance of specific taxonomies due to having files specific to that term. taxonomy-{taxonomy}-{slug}.php. Visit Template Hierarchy

Leave a Comment