我已经尝试了几乎所有与此问题有关的所有方法,但是我没有得到任何好的结果,我想知道这有什么问题,单击数字2时,URL变为page / 2,但是活动链接在1上保持活动状态。
<?php
if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
else { $paged = 1; }
$wp_mainblog_query = new WP_Query(array('posts_per_page' => '3' , 'paged' => $paged ));
if($wp_mainblog_query->have_posts()) :
while($wp_mainblog_query->have_posts()) :
$wp_mainblog_query->the_post();
$mainblog_img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID));
?>
<div class="col-lg-6 col-md-6">
<div class="single-post-item">
<div class="post-thumb">
<img class="img-fluid" src="<?php echo $mainblog_img[0]; ?>" alt="">
</div>
<div class="post-details">
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<p><?php $mainblog_content = get_the_content(); echo mb_strimwidth($mainblog_content, 0, 10) ?></p>
<div class="blog-meta">
<a href="<?php the_permalink(); ?>" class="m-gap">
<span class="lnr lnr-calendar-full"></span>
<?php echo get_the_date(); ?>
</a>
<a href="#" class="m-gap">
<span class="lnr lnr-bubble"></span>05
</a>
</div>
</div>
</div>
</div>
<?php
endwhile;
?>
<?php
// wp_reset_postdata();
endif;
?>
<div class="col-lg-12 text-center" >
<?php
echo paginate_links(array(
'total' => $wp_mainblog_query->max_num_pages
// 'prev_text' => '<span class="lnr lnr-arrow-left"></span>',
// 'next_text' => '<span class="lnr lnr-arrow-right"></span>'
));
?>
</div>
代码在front-page.php文件中。