I need to
get category id in
single.php. I tried this:
$cat_ID = get_query_var('cat');
It didn't work. What should I use instead?
Retrieve the list of categories for a post.
Be aware that the function returns an array (of category ids) even if you only have one category in your post.
The example below shows how categories are retrieved, and then additional information is retrieved for each category.
You can simply use
to get the assigned categories.