您可以这样尝试:在$args之前添加以下内容
if( get_query_var( \'paged\' ) ):
$my_page = get_query_var( \'paged\' );
else:
if( get_query_var( \'page\' ) ):
$my_page = get_query_var( \'page\' );
else:
$my_page = 1;
endif;
$paged = $my_page;
用此替换分页代码(请确保在
endwhile
):
$total = $projects->found_posts;
$page = isset( $_GET[\'page\'] ) ? abs( (int) $_GET[\'page\'] ) : 1;
$format = \'page/%#%/\';
$current_page = max(1, $paged);
$big = 999999999;
echo paginate_links( array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'?page=%#%\',
\'end_size\' => 1,
\'mid_size\' => 2,
\'prev_next\' => True,
\'prev_text\' => \'prev\',
\'next_text\' => \'next\',
\'type\' => \'plain\',
\'add_args\' => False,
\'add_fragment\' => \'\',
\'before_page_number\' => \'\',
\'after_page_number\' => \'\',
\'total\' => ceil($total / $posts_per_page),
\'current\' => $current_page,
));