Ghugu
Ghugu

Reputation: 489

Get slug using term id

I need help I googled almost everything but not getting category slug using term_id $term_id

Please help sorry if this question is asked before

Thanks in advance

Upvotes: 5

Views: 14783

Answers (3)

Max
Max

Reputation: 674

$term_slug = get_term_field( 'slug', 'your_term_id', 'your_taxonomy' );

Upvotes: 1

Ash0ur
Ash0ur

Reputation: 1545

$term_object = get_term( $term_id );
$term_object->slug;

Upvotes: 7

Mtxz
Mtxz

Reputation: 3869

You can use $term = get_term_by('id', $id) see get_term_by() codex page.

Then access slug using $term->slug.

Upvotes: 3

Related Questions