WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

I have a hierarchical taxonomy called 'tarefa'

I have to display all posts from a child taxonomy. I used get_term_children function function to verify if the taxonomy parent has children.

If the taxonomy parent has children I will query posts by taxonomy children.

The problem is:
I have to query posts by taxonomy slug but the function get_term_children return an array of taxonomy IDS.

The question is:
How can I return a taxonomy slug by a taxonomy ID?

share|improve this question
up vote 5 down vote accepted

I have bit of trouble understanding your question. Taxonomy (like category) slug or term (like uncategorized) slug?

get_term_children() works with terms so I will stick with that.

Try this:

$term = get_term( $id, $taxonomy );
$slug = $term->slug;
share|improve this answer
I wasn't familiar with this function, it worked as expected ;) thanks. – Sergio Soares Oct 6 '10 at 11:23
Is there a way to do this with less overhead? – Odys Dec 20 '14 at 12:07

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.