2017-12-12 8 views
0

Wordpressのトップスライダーを私の2,3,4 ...のブログページでPHPで隠す方法はありますか?これは私のスクリプトです:最初のブログページ以外のブログページからスライダーを隠すにはどうすればよいですか?

<section id="blog"> 
     <div class="owl-carousel"> 
      <?php $loop = new WP_Query(array('post_type' => 'post', 'posts_per_page' => -1, 'orderby'=> 'ASC')); ?> 
      <?php while ($loop->have_posts()) : $loop->the_post(); ?> 
      <div class="recent-post"> 
       <div class="home-slider-img"> 
        <?php echo the_post_thumbnail(); ?> 
       </div> 
       <div class="feat-overlay"> 
        <div class="feat-overlay-inner"> 
         <div class="post-header">      
          <span class="cat"><?php the_category(', ') ?></span> 
          <h4><a href="<?php the_permalink(); ?>"><?php print get_the_title(); ?></a></h4> 
          <span class="date"><?php the_time('M j, Y') ?></span> 
          <p><a class="read-more" href="<?php print get_permalink($post->ID) ?>">Read More</a></p> 
         </div>  
        </div> 
       </div> 
      </div> 
      <?php endwhile; ?> 
     </div> 
    </section> 

答えて

0

is_home()機能は、あなたが欲しいものを行う必要があります - あなたは、このようなブログのホームページにしている場合は、テストをチェックする場合https://developer.wordpress.org/reference/functions/is_home/

ちょうどにあなたのowl-carouselのdivをラップ:

<?php if (is_home()) { ?> 
    <div class="owl-carousel">...</div> 
<?php } ?> 
+0

これは動作しませんが、これで試してみます: <?php if(!is_paged()){?> !ありがとうございました! –