直接上代码:
<?php
$args=array(
'cat' => 1, // 分类ID
'posts_per_page' => 10, // 显示篇数
);
query_posts($args);
if(have_posts()) : while (have_posts()) : the_post();
?>
<div class="post">
<!-- Post Title -->
<h3 class="title"><a href="<?php the_permalink();?>" rel="bookmark"><?php the_title();?></a></h3>
<!-- Post Data -->
<p class="sub"><a href="#">News</a>, <a href="#">Products</a> • 31st Sep, 09 • <a href="#">1 Comment</a></p>
<div class="hr dotted clearfix"> </div>
<!-- Post Image
<img class="thumb" alt="" src="images/610x150.gif" />-->
<!-- Post Content -->
<?php the_excerpt(); ?>
<!-- Read More Button -->
</div>
<div class="hr clearfix"> </div>
<?php endwhile; endif; wp_reset_query(); ?>
$args:是要显示的分类的参数。
query_posts():可以用来控制在循坏(Loop)中显示哪些文章。
下面的添加循环和条件判断,还有标题,内容的输出 大家应该知道了。