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

ok - so i'm listing categories and their sub-categories. How can i get the ID of the category that's being shown with a function? ( i know what it is in the admin )

ie /category/events/women-in-art/

women-in-art-ID = ?

any help appreciated! Dan.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

How about get_query_var('cat'). I think that should get the ID of the current category.

share|improve this answer
that's it! Thnks - got a bit stuck trying to use get_the_category(). – daniel Crabbe Mar 24 '11 at 17:45

The "official" way to get the ID of the current category is get_queried_object_id() (also works with tags and custom taxonomies).

share|improve this answer
Cool. I used get_queried_object()->term_id until now. – toscho Mar 25 '11 at 0:35

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.