首先,需要获取分页查询变量并将其传递给主查询参数:
//Protect against arbitrary paged values
$paged = ( get_query_var( \'paged\' ) ) ? absint( get_query_var( \'paged\' ) ) : 1;
$args = array(
\'post_type\' => \'post\'
\'paged\' => $paged,
);
然后,必须在要显示分页的位置添加以下代码:
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'?paged=%#%\',
\'current\' => max( 1, get_query_var(\'paged\') ),
\'total\' => $post_query->max_num_pages
) );
?>