How can I retrieve slug of current taxonomy being viewed in taxonomy template? I tried to codex but found nothing on taxonomy template page.
To further explain, lets say I am viewing category flowers so how can I retrieve slug of category flowers?
1
You can get the term object of the category you’re viewing with get_queried_object()
. That will contain the slug.
$term = get_queried_object();
echo $term->slug;