foreach((get_the_category()) as $category) { echo $category->cat_ID . ' '; //当前文章的分类的ID echo $category->cat_name . ' '; //当前文章的分类的名称}