wordpress模板中的elseif
如果没有贴子,我如何添加一些echo来渲染一个paragrafwordpress模板中的elseif,wordpress,if-statement,Wordpress,If Statement,如果没有贴子,我如何添加一些echo来渲染一个paragraf <?php query_posts('cat=1'.get_the_title().'&post_status=publish,future');?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <div class="thu
<?php query_posts('cat=1'.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="thumb"><?php the_post_thumbnail('thumbnail'); ?></div>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p><?php $content = get_the_content();
echo substr($content, 0, 20000); ?>...
<span class="more"><a href="<?php the_permalink(); ?>">czytaj więcej...</a></span>
</p>
<?php endwhile; ?>
<?php endif; ?>
。。。
您可以在while
循环之后放置else
:
<?php endwhile; ?>
<?php else: ?>
<p> no posts found</p>
<?php endif; ?>
没有找到帖子
。。。
<?php query_posts('cat=1'.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="thumb"><?php the_post_thumbnail('thumbnail'); ?></div>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p><?php $content = get_the_content();
echo substr($content, 0, 20000); ?>...
<span class="more"><a href="<?php the_permalink(); ?>">czytaj więcej...</a></span>
</p>
<?php endwhile; ?>
<?php else : ?>
<!-- Content to show when there are no posts. -->
<?php endif; ?>