2014-01-30 61 views
-1

我需要將分頁添加到存檔頁面。每頁顯示10個月。WordPress的 - 如何添加分頁到存檔頁面?

wp_get_archives('type=monthly&show_post_count=1'); 
+0

什麼樣的分頁的?帶數字?上一個/下一個帖子?你嘗試了什麼? – enguerranws

+0

我使用http://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin – user3214264

+0

因此,使用<?php kriesi_pagination(); ?>,因爲它被寫入? – enguerranws

回答

0

試試這個

          <?php 

             $catnam = '1'; 

             $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
             // the total of registers to show on each page 
             $showp = 4; 

             wp_get_archives("type=monthly&showposts=$showp&paged=$paged");  


             while (have_posts()) : the_post();?> 

             <h4><a href="<?php echo get_permalink(); ?>"><?php the_title();?></a></h4> 

             <?php endwhile;?> 

             <?php 
              global $wp_rewrite; 
              $paginate_base = get_pagenum_link(1); 
              if (strpos($paginate_base, '?') || ! $wp_rewrite->using_permalinks()) { 
               $paginate_format = ''; 
               $paginate_base = add_query_arg('paged', '%#%'); 
              } else { 
               $paginate_format = (substr($paginate_base, -1 ,1) == '/' ? '' : '/') . 
                user_trailingslashit('page/%#%/', 'paged');; 
               $paginate_base .= '%_%'; 
              } 

              echo '<div id="pagination">'; 
              echo paginate_links(array(
               'base' => $paginate_base, 
               'format' => $paginate_format, 
               'total' => $wp_query->max_num_pages, 
               'mid_size' => 10, 
               'current' => ($paged ? $paged : 1), 
               'type' => '', 
               'prev_text' => __('<p class="readmore">&laquo; Previous</p>', 'default'), 
               'next_text' => __('<p class="readmore">Next &raquo;</p>', 'default'), 
              )); 
              echo "</div>"; 
             ?>