我正在尝试将分页添加到我的网站,但它不起作用。代码如下:
<div id="gridcontainer" class="carousel">
<?php
$currentPage = get_query_var(\'page\');
$counter = 1; //start counter
$grids = 2; //Grids per row
global $query_string; //Need this to make pagination work
$mosaicoMenu = new WP_Query(array(
\'post_type\' => \'artist\',
\'orderby\' => \'title\',
\'order\' => ASC,
\'posts_per_page\' => 8,
\'page\' => $currentPage
));
if($mosaicoMenu->have_posts()) :
while($mosaicoMenu->have_posts()) :
$mosaicoMenu->the_post();
//Show the left hand side column
if($counter == 1) :
?>
<div class="griditemleft">
<div class="artista no-padding no-margin" style="background-image: url(<?php the_post_thumbnail_url(); ?>), url(\'https://i.postimg.cc/9QS9Mn00/gradient2.png\');">
<p><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?><span>+</span></a></p>
</div>
</div>
<?php
//Show the right hand side column
elseif($counter == $grids) :
?>
<div class="griditemright">
<div class="artista no-padding no-margin" style="background-image: url(<?php the_post_thumbnail_url(); ?>), url(\'https://i.postimg.cc/9QS9Mn00/gradient2.png\');">
<p><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?><span>+</span></a></p>
</div>
</div>
<div class="clear"></div>
<?php
$counter = 0;
endif;
$counter++;
endwhile;
echo paginate_links(array(
\'total\' => $mosaicoMenu->max_num_pages
));
endif;
wp_reset_postdata();
?>
</div>
一切看起来都很好,但当我单击分页链接时,它会将我带到同一页。顺便说一句,我在静态首页上使用这个。