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

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。