<?php
$cat_query = new WP_Query(array(
'cat' => '2'
));
?>
<div id="sitebar">
<ul class="nav nav-pills nav-stacked nav-og">
<?php
if ($cat_query->have_posts()) : while ($cat_query->have_posts()) : $cat_query->the_post();
?>
<li><a href=“<?php the_permalink() ?> title=“<?php the_title(); ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
这是调用cat-id为2的分类下的文章,就是后台分类链接的tag_ID
其中
获取当前分类id代码为
get_query_var('cat')