六、Wordpress如何循环输出文章列表

have_posts() 判断是否有文章
the_post() 下一篇文章
the_title() 文章标题
the_permalink() 文章链接
the_content() 文章内容
<div id="home-loop">
<?
if( have_posts() ){
while( have_posts() ){
//获取下一篇文章的信息,并且将信息存入全局变量 $post 中
the_post();
?>
<div class="post-item">
<div class="post-title"><h2><a href="<? the_permalink(); ?>"><? the_title(); ?></a><h2></div>
<div class="post-content"><? the_content(); ?></div>
</div>
<?
}
}else{
echo '没有日志可以显示';
}
?>
</div>
<div id="home-loop">
<?php
if( have_posts() ){
while( have_posts() ){
//获取下一篇文章的信息,并且将信息存入全局变量 $post 中
the_post();
?>
<div class="post-item">
<div class="post-title"><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><h2></div>
<div class="post-content"><?php the_content(); ?></div>
<div class="post-meta">
<?php the_category(','); ?><span>|</span>
<?php the_author(); ?><span>|</span>
<?php the_time( 'Y-m-d' ); ?>
<?php edit_post_link('Edit', ' <span>|</span> ', '' ); ?>
</div>
</div>
<?php
}
}else{
echo '没有日志可以显示';
}
?>
</div>