好的,我知道已经有很多关于这个的帖子了,但我无法找到我的代码有什么问题。因为分页仍不起作用。奇怪的是,相同的代码和模板在我使用它们的另一个站点上运行良好。
<?php
$type = get_sub_field(\'type\');
$amount = get_sub_field(\'amount\');
$previousLabel = $labels[\'previous_label\'];
$nextLabel = $labels[\'next_label\'];
?>
<div class="block-review block-review-<?php echo($type)?>">
<div class="content-wrapper">
<?php
if($type == \'list\') {
// get list of posts
$pageQuery = (is_home())? \'page\' : \'paged\';
$paged = (get_query_var($pageQuery)) ? get_query_var($pageQuery) : 1;
$reviews = new WP_Query(
array(
\'post_type\' => \'review\',
\'posts_per_page\' => $amount,
\'paged\' => $paged,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
\'meta_key\' => \'meta_data_hide_review\',
\'meta_value\' => \'0\'
)
);
// loop though reviews
if ($reviews->have_posts()):
while($reviews->have_posts()): $reviews->the_post();
require(\'element/review-item.php\');
endwhile;
?>
<div style="display:none"><?php var_dump(get_query_var(\'page\') . get_query_var(\'paged\'))?></div>
<div class="review-pagination-wrapper">
<div class="review-pagination">
<?php
echo paginate_links( array(
\'base\' => str_replace( 999999999, \'%#%\', esc_url( get_pagenum_link( 999999999 ) ) ),
\'total\' => $reviews->max_num_pages,
\'current\' => max( 1, get_query_var( $pageQuery ) ),
\'format\' => \'?\' . $pageQuery . \'=%#%\',
\'show_all\' => false,
\'type\' => \'plain\',
\'end_size\' => 2,
\'mid_size\' => 1,
\'prev_next\' => true,
\'prev_text\' => sprintf( \'<i></i> %1$s\', __( $previousLabel , \'text-domain\' ) ),
\'next_text\' => sprintf( \'%1$s <i></i>\', __( $nextLabel , \'text-domain\' ) ),
\'add_args\' => false,
\'add_fragment\' => \'\',
) );
?>
</div>
</div>
<?php
else:
// no posts
endif;
wp_reset_postdata();
}
?>
</div>
</div>
因此,第一页工作正常,分页显示,但我无法导航到下一页。任何帮助都将不胜感激。