尝试使用自定义WP\\U查询,以排除任何可能的代码干扰主查询分页。像这样:
<?php
$paged = ( get_query_var( \'paged\' ) ) ? get_query_var( \'paged\' ) : 1;
$query = new WP_Query( array( \'post_type\' => \'post\', \'post_status\' => \'publish\', \'posts_per_page\' => 5, \'paged\'=> $paged) );
?>
<?php while($query->have_posts()) : $query->the_post(); ?>
<div class="blogcontent">
<div class="post_img"><a href="<?php the_permalink(); ?>">
<?php $img = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<?php $image_alt = get_post_meta( get_post_thumbnail_id($post->ID), \'_wp_attachment_image_alt\', true); ?>
<?php if($img) { ?>
<img src="<?php echo $img; ?>" alt="<?php echo $image_alt; ?>">
<?php } ?></a></div>
<div class="post_content">
<?php
$category_detail=get_the_category($post->ID);//
foreach($category_detail as $cd){ ?>
<a href="<?php echo get_home_url(); ?>/category/<?php echo $cd->slug; ?>/"><span class="boldtag"><?php echo $cd->cat_name; ?></span></a>
<?php }
?>
<h1><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h1>
<?php the_excerpt(); ?>
<ul class="author clearfix">
<li>By <em><?php the_author_posts_link(); ?></em> <span>· <?php the_time(\'M d, Y\') ?></span></li>
<li><a href="<?php the_permalink(); ?>">MORE...</a></li>
</ul>
</div>
</div>
<?php endwhile; ?>
<div class="paginationsec">
<nav class="navigation pagination show">
<div class="nav-links">
<?php
echo paginate_links( array(
\'base\' => str_replace( 999999999, \'%#%\', esc_url( get_pagenum_link( 999999999 ) ) ),
\'total\' => $query->max_num_pages,
\'current\' => $paged,
\'format\' => \'?page=%#%\',
\'show_all\' => false,
\'type\' => \'plain\',
\'end_size\' => 5,
\'mid_size\' => 1,
\'prev_next\' => true,
\'prev_text\' =>__( \'<i class="fa fa-angle-double-left"></i> Prev\', \'twentyfifteen\' ),
\'next_text\' => __( \'Next <i class="fa fa-angle-double-right"></i>\', \'twentyfifteen\' ),
\'before_page_number\' => \'<span class="meta-nav screen-reader-text">\' . __( \'\', \'twentyfifteen\' ) . \' </span>\',
\'add_args\' => false,
\'add_fragment\' => \'\',
) );
?>
</div>
</nav>
</div>