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.

This might be very basic question, but I can't really get the category ID on category page (actually a category page of custom type post).

Filename is taxonomy-item-category.php & URL is http://www.abc.com/cat/food/

I have tried some of the following but not working...

$cur_cat_id = get_cat_id( single_cat_title( "food", false ) );
$cur_cat_id = get_cat_id( single_cat_title( "", false ) );

get_the_category( "food" );

How can I get the category ID on category page?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

$cat_id = get_queried_object_id(); - it's that simple!

share|improve this answer
    
Thanks so much. It's simple but It wasn't so easy for newbie. Thanks again. –  pulla Jun 24 '13 at 9:08
add comment

Maybe this is more easy way to find ID

Find Category Id in Wordpress

share|improve this answer
    
Answers should be more than outgoing links. Please answer the question in here. If the link was of help or you've taken something from there, use it for quotes or as reference. –  kaiser Sep 29 '13 at 5:39
add comment

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.