WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I wanted to get the category ID for the current post, I would use something like this:

<?php foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '; } ?>

How can I do the same for a a term ID from a specific Taxonomy?

share|improve this question

Thanks helgatheviking, it didn't work as is but you definitely set me on the right path. I got it working by doing the following:

<?php foreach((get_the_terms($post->ID, 'your-taxonomy-here')) as $term) { echo $term->term_id. ''; } ?>

Replace "your-taxonomy-here" with your own and your ready to go.

share|improve this answer

See get_the_terms(), you'd do something like so:

foreach((get_the_terms($post->ID) as $term) { echo $term->term_id. '<br/>'; }
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.