Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

On a category archive page, how do I determine what category the archive page is for? I need either the id or the slug of the category.

I am not looking for get_the_category(). This will give me all categories of the posts on this page (which can be subcategories of the category that the page is for). Instead, I want the category that the archive page is for. How can I get this category?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

the ID of the current category will be available in the cat query var:

get_query_var('cat');
share|improve this answer
1  
Thank you, I'm using this to highlight items in my category-based navigation, and now it finally works correctly for all possible cases! Also, I just found an example that explains how to get more details about the category on codex.wordpress.org/Function_Reference/… –  Ben Sep 22 '11 at 17:09

Your Answer

 
discard

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.