为什么要使用WP-PageNavi 用于基于数字的分页。WordPress提供了一种实现这一点的方法。顺便说一句,这里是供您在家中使用的完整查询。php
<div id="main-content">
<div class="container">
<section id="content" class="blog">
<?php
if ( get_query_var(\'paged\') ) { $paged = get_query_var(\'paged\'); } elseif ( get_query_var(\'page\') ) { $paged = get_query_var(\'page\'); } else { $paged = 1; }
$args = array(
\'post_type\' => \'post\',
\'paged\' => $paged
);
$my_query = new WP_Query( $args );
if ( $my_query->have_posts() ) :
while ( $my_query->have_posts() ) : $my_query->the_post();
get_template_part( \'content\', \'blog-index\' );
endwhile;
if ( $my_query->max_num_pages > 1 ) :
$big = 999999999;
echo \'<div class="pagination">\';
echo paginate_links( array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'?paged=%#%\',
\'current\' => max( 1, get_query_var(\'paged\') ),
\'total\' => $my_query->max_num_pages
) );
echo \'</div>\';
endif;
else :
get_template_part( \'content\', \'none\' );
endif;
wp_reset_postdata();
?>
</section>
<?php get_sidebar( \'blog\' ); ?>
</div>
</div>