Get term SLUG by term ID

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.

Read More

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?

Related posts

Leave a Reply

1 comment

  1. 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;