June 26, 2015
Retrieve the ID of the first item in a loop:
$category = get_the_category(); echo $category[0]->cat_name;
Retrieve the ID of the current category in the category.php or single.php page template:
$category = get_category( get_query_var( 'cat' ) ); $cat_id = $category->cat_ID;