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?


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

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

Maybe this is more easy way to find ID

Find Category Id in Wordpress

| 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

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.