在用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; ?>

觉得上面的内容有用吗?快来点个赞吧!

点赞() 我要打赏

温馨提示 : 本站内容来自会员投稿以及互联网,所有源码及教程均为作者总结编辑,请大家在使用过程中提前做好备份,以免发生无法预知的错误,源码类教程请勿直接用于生产环境!

 可能感兴趣的文章