wordpress分页每页显示的都是相同的内容

wordpress分页每页显示的都是相同的内容

今天查看网站的时候,发现有一个分类的所有分页页面显示的都是相同的内容,而其他页面是正常的。解决办法是在分页代码中加入如下参数:

'paged' => get_query_var( 'paged' ),

最终分页代码如下:

<div class="row">
    <?php 
        $args = array( 
            'cat'            => $cat,
            'post__not_in'   => get_option( 'sticky_posts' ) ,
            'posts_per_page' => 10,
            'paged' => get_query_var( 'paged' ),
        ); 
        $query = new WP_Query( $args ); 
        while ( $query->have_posts() ) : $query->the_post();
    ?>
    <div class="col-lg-6 p-lg-5 my-1">
        <a href="<?php the_permalink(); ?>">
            <img src="<?php the_post_thumbnail_url(); ?>" class="d-block py-2 px-5 w-100">
            <h2 class="post-person-title"><?php the_title(); ?></h2>
        </a>
    </div>
    <?php endwhile; wp_reset_query();?>
</div>
<?php the_posts_pagination( array('mid_size' => 3, 'prev_text' =>'<', 'next_text' =>'>') ); ?>
wordpress分页每页显示的都是相同的内容

相关文章:

你感兴趣的文章:

标签云: