2017-02-05 4 views
2

次のように数値改ページでループ:、複数のWordpressのループ、2ページ目に最初のループを隠す

<div class="container" style="background:#ccc"> 
      <? 
       $paged2 = isset($_GET['paged2']) ? (int) $_GET['paged2'] : 1; 

       // Custom Loop with Pagination 1 
       // http://codex.wordpress.org/Class_Reference/WP_Query#Usage 
       $args1 = array(
        'paged'   => false, 
        'category_name' => 'latest', 
        'posts_per_page' => 1, 
       ); 
       $query1 = new WP_Query($args1); 

       while ($query1->have_posts()) : $query1->the_post(); 
        the_title(); 
        the_category(' '); 
        the_excerpt(); 
       endwhile; 

      ?> 
      <!-- second --> 
      <? 
       $args2 = array(
        'paged'   => $paged2, 
        'category_name' => 'uncategorized', 
        'posts_per_page' => 2, 
       ); 
       $query2 = new WP_Query($args2); 

       while ($query2->have_posts()) : $query2->the_post(); 
        the_title(); 
        the_category(' '); 
        the_excerpt(); 
       endwhile; 

       $pag_args2 = array(
        'format' => '?paged2=%#%', 
        'current' => $paged2, 
        'total' => $query2->max_num_pages, 
        'add_args' => array('paged1' => $paged1) 
       ); 
       echo paginate_links($pag_args2); 
      ?> 
    </div> 
    <!-- container --> 

すべてが正常に動作しますが、paginatinのページには、「最新の」ポストループを示しページングをfalseに設定していますが ページ分割ページの最初のループを非表示にするにはどうすればよいですか? アドバイスありがとうございます。

答えて

0

使用wp_reset_postdata()関数で、あなたのループ終了 後にこのコードに従って、それはあなたの

<?php 
// example args 
$args = array('posts_per_page' => 3); 

// the query 
$the_query = new WP_Query($args); 
?> 

<?php if ($the_query->have_posts()) : ?> 

    <!-- start of the loop --> 
    <?php while ($the_query->have_posts()) : $the_query->the_post(); ?> 
     <?php the_title(); ?> 
     <?php the_excerpt(); ?> 
    <?php endwhile; ?><!-- end of the loop --> 

    <!-- put pagination functions here --> 
    <?php wp_reset_postdata(); ?> 

<?php endif; ?> 
+0

をお手伝いしますかもしれこんにちは、残念ながら最初のループは、これを追加した後にページネーションページに表示されたままです。 – user3615851

関連する問題