如果某个类别的没有帖子,我会尝试显示一条消息
<?php $recent = new WP_Query("cat=9&showposts=10");
while($recent->have_posts()) : $recent->the_post();?>
<?php the_title(); ?>
<?php the_content();?>
<?php endwhile; ?>
但当我添加"其他"时,我会得到空白屏幕
<?php else: ?>
message ////
<?php endif; ?>
您可以执行以下操作<?php
if ( have_posts() )
{
while ( have_posts() ) : the_post();
// Your loop code
endwhile;
}
else {
echo 'Sorry, no posts were found';
}
?>