Accessing Custom Taxonomy of a Custom Post Type in the_loop

I was wondering how to access the custom taxonomy of my custom post types so it can be mentioned in the_loop. To continue my example from earlier posts, I have custom post type of “game”, with a custom taxonomy of “platform”. When I list a game, I’d like to show the platform in a list after its title.

On regular posts, I have access to access to both categories and tags using the get_the_category() or get_the_tags() functions. For my project I have a custom query for the custom post type, and I’m using a custom taxonomy on it. I’d like to find out the name of that custom taxonomy. How do we do that?

We’ll use get_the_terms(), which is used by WordPress for both the above functions under the hood. Here’s how we can display all taxonomies of one type (must be used in the_loop):

Thanks to Ankur Bhadiania for this tip.

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!