我需要为归档页面添加分页。每页显示10个月。
wp_get_archives('type=monthly&show_post_count=1');
答案 0 :(得分: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">« Previous</p>', 'default'),
'next_text' => __('<p class="readmore">Next »</p>', 'default'),
));
echo "</div>";
?>