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…
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…
you can use get_queried_object()
$category = get_queried_object();
echo $category->term_id;