I'd like to get term data from a custom taxonomy associated with the current post.

I can do this with get_the_term_list($id $custom_taxonomy). However, this returns the data I want wrapped in HTML.

I'd like to get the data but not wrapped in HTML.

I presume this means using a function that returns an object, and from that point I'd work with the object. get_terms looks like a likely candidate. But I haven't been able to craft the parameters correctly.

How exactly can I get the data I want?


OK, so let's make it straight:



So it will generate HTML code and return it as string.


Retrieves the terms in a given taxonomy or list of taxonomies.

So it has nothing to do with current post.


Retrieve the terms of the taxonomy that are attached to the post.

So this is the one you're looking for, I guess.

It will get the terms of given taxonomy that are assigned to given post and return them as array - so you can iterate it and do whatever you want with them...

  • This cleared things up nicely and gave me a path to a solution. Thanks! – bob May 30 '18 at 22:45
  • @bob No problem :) – Krzysiek Dróżdż May 30 '18 at 22:46

Your Answer

