下面的循环获取相关类别中的所有帖子。它确实会生成分页URL,但它不会将我带到那里(它只是重定向回主页)。
有人知道为什么吗?
$paged = (get_query_var(\'page\')) ? get_query_var(\'page\') : 1;
$category_cat_args =
array(
\'category_name\' => $current_category,
\'posts_per_page\' => 2,
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'&paged\' => $paged
);
$wp_query = new WP_Query( $category_cat_args );
?>
<div class="category-page">
<div class="col68-2r">
<h1 class="post-title">
<?php echo $current_category; ?> news</h1>
<?php
if ( $wp_query->have_posts() ):
while ( $wp_query->have_posts() ):
$wp_query->the_post();
$images = get_field( \'gallery\' );
if ( $images ):
?>
<div class="col33">
<div class="img-ctnr">
<a href="<?php the_permalink();?>">
<img src="<?php echo $images[0][\'url\'];?>" alt="example-image">
<?php bottom_note(); ?>
</a>
</div>
</div>
<?php
endif;
endwhile;
else: echo "There are no posts in this category";
endif;
?>
<?php wp_pagenavi( array( \'query\' => $wp_query ) ); ?>
<div class="clear"></div>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<a href="<?php echo get_next_posts_page_link(); ?>" class="btn-ar"> more articles</a>
<?php endif; ?>
<?php wp_reset_postdata(); ?></div>