WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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