I’m trying to get category ID of the current archive displayed.

I tried:

// category (can be a parent category)
$current_cat_ID = get_query_var('cat');
//
print_r ($current_cat_ID);

It doesn’t print anything…

3

you can use get_queried_object()

$category = get_queried_object();
echo $category->term_id;

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *