2

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?

10

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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