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.


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

| improve this answer | |
  • that's it! Thnks - got a bit stuck trying to use get_the_category(). – v3nt 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).

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

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.