我在home.php中有一个posts循环
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 2
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
the_title();
the_content();
}
wp_reset_postdata();
} ?>如何添加分页(数字)?我找了一本教程。我尝试了很多函数,但都不起作用。
谢谢
发布于 2019-01-14 07:40:39
使用下面的代码应该是可能的:
<?php the_posts_pagination( array( 'mid_size' => 2 ) ); ?>mid_size定义在该行中当前页面两侧显示的页码数量。
有关更多详细信息,包括上一页/下一页链接的单独文本,请参阅:
https://codex.wordpress.org/Function_Reference/the_posts_pagination
https://stackoverflow.com/questions/54173816
复制相似问题