<?php
$cat= single_cat_title('', false);
echo get_cat_ID($cat);
?>
第四种:<?php
if (!is_page() && !is_home()){
$catsy = get_the_category(); $myCat = $catsy[0]->cat_ID; $currentcategory = '¤t_category='.$myCat;
}
wp_list_categories('hierarchical=1&use_desc_for_title=0&exclude=12&depth=1&orderby=id&title_li='.$currentcategory);
?>
<?php
foreach((get_the_category()) as $category) {
echo $category->cat_ID . ''; //当前文章的分类的ID
echo $category->cat_name . ''; //当前文章的分类的名称
}
?>