2014-03-07 83 views
0

我有以下循環,這是假設拉動所有分類稱爲系列和它下面的帖子。它工作正常,但問題是它不是顯示舊帖子鏈接。我手動轉到第二頁更新的帖子鏈接顯示出來。任何想法我錯過了什麼?WordPress的分類學循環分頁 - 較舊的文章鏈接不顯示

   <?php 
       $page = (get_query_var('paged')) ? get_query_var('paged') : 1; 
       $per_page = 5; 
       $offset = ($page-1) * $per_page; 
       $args = array('number' => $per_page, 'offset' => $offset, 'hide_empty' => 0,'paged' => $page); 
       $terms = get_terms('series',$args); 

      foreach ($terms as $term) { 
       $wpq = array ('taxonomy'=>'series','term'=>$term->slug); 
       $myquery = new WP_Query ($wpq); 
       $article_count = $myquery->post_count; 
       echo "<h3 class=\"term-heading\" id=\"".$term->slug."\">"; 
       echo $term->name; 
       echo "</h3>"; 
       if ($article_count) { 
       echo "<ul>"; 
       while ($myquery->have_posts()) : $myquery->the_post(); 
        echo "<li><a href=\"".get_permalink()."\">".$post->post_title."</a></li>"; 
       endwhile; 
       echo "</ul>"; 
       } } ?> 

     <div class="clear"></div> 
      <p class="previous"><?php next_posts_link(__('&larr; Older posts', 'ari')); ?></p> 
      <p class="next"><?php previous_posts_link(__('Newer posts &rarr;', 'ari')); ?></p> 
    </div> 

回答

0

試試這個(我測試過),分頁不工作好有偏移,這是get_terms)更好的((但仍然有用get_query_var(「分頁」)),也改變「類別」來你想要的術語。

<?php 
$page = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$per_page = 4; 
$offset = ($page-1) * $per_page; 
$args = array('number' => $per_page, 'offset' => $offset, 'hide_empty' => 0); 
$terms = get_terms('category', $args); 

foreach ($terms as $term){ 
    $wpq = array ('taxonomy'=>'category','term'=>$term->slug); 
    $myquery = new WP_Query ($wpq); 
    $article_count = $myquery->post_count; 
    echo "<h3 class=\"term-heading\" id=\"".$term->slug."\">"; 
    echo $term->name; 
    echo "</h3>"; 
    if ($article_count){ 
    echo "<ul>"; 
    while ($myquery->have_posts()) : $myquery->the_post(); 
    echo "<li><a href=\"".get_permalink()."\">".$post->post_title."</a></li>"; 
    endwhile; 
    echo "</ul>"; 
    } 
    } ?> 
+0

我刪除了偏移量,仍然沒有顯示舊的後期鏈接。 – Wolverine