2013-10-10 2 views
-1

게시물이없는 경우 어떻게 paragraf를 렌더링하는 데 에코를 추가 할 수 있습니까?WordPress 템플릿의 elseif

  <?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; ?> 

답변

0

당신이 while 루프 후 else을 넣을 수 있습니다 :

 <?php endwhile; ?> 

    <?php else: ?>  

    <p> no posts found</p> 

<?php endif; ?> 
0
<?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; ?>