WordPress 查询调用文章所属的分类id,根据文章id查cat分类栏目id方法

在用query_posts()调用文章列表时,想同时调用每个文章所对应的栏目分类id号,怎么办呢?可以这样:

<?php 
query_posts( array( 'post__not_in' => $sticky,'cat'=>'6','showposts'=>'6', 'caller_get_posts' => 1 ) );  
//print_r(query_posts());exit; 
while(have_posts()) : the_post(); 
$title = get_the_title();            
?> 
<li> 
<span class="cat color-1"> 
<?php $cats=get_the_category(); 
foreach($cats as $cat) echo $cat->cat_ID; 
?> 
这是分类id号</span> 
</li> 
<?php endwhile; ?>


WordPress