have_posts() 有没有文章信息
if...else
<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?> <!-- 在这里调用数据 --> <?php endwhile; ?> <?php endif; ?>
if....else.if ...else
<?php if( have_posts() ) : while( have_posts() ) : the_post(); ?> <!-- 在这里调用数据 --> <?php endwhile; ?> <?php else: ?> <!-- 如果没有数据则显示什么 --> <?php endif; ?>
参考文档:
http://codex.wordpress.org/The_Loop
http://codex.wordpress.org/The_Loop_in_Action
原文:http://www.cnblogs.com/tinyphp/p/6350264.html