我怀疑你的问题在这里:
\'base\' => get_pagenum_link(1) . \'%_%\'
你通过了
1
到
get_pagenum_link()
, 而不是实际的页码。尝试通过之前确定的
$current_page
而是:
\'base\' => get_pagenum_link( $current_page ) . \'%_%\'
注意,我将此用作
base
:
\'base\' => @add_query_arg(\'paged\',\'%#%\')
编辑我尝试了你的建议以及
\'@add_query_arg\'
这两种方法都没有实际更新下一组帖子的分页。url更改为“/besh/page/2”,但帖子不变,页码保持在1。这就好像我的代码中完全遗漏了一些东西。
我所能做的就是为您提供完整的工作代码:
/**
* Paginate Archive Index Page Links
*/
function oenology_get_paginate_archive_page_links( $type = \'plain\', $endsize = 1, $midsize = 1 ) {
global $wp_query, $wp_rewrite;
$wp_query->query_vars[\'paged\'] > 1 ? $current = $wp_query->query_vars[\'paged\'] : $current = 1;
// Sanitize input argument values
if ( ! in_array( $type, array( \'plain\', \'list\', \'array\' ) ) ) $type = \'plain\';
$endsize = (int) $endsize;
$midsize = (int) $midsize;
// Setup argument array for paginate_links()
$pagination = array(
\'base\' => @add_query_arg(\'paged\',\'%#%\'),
\'format\' => \'\',
\'total\' => $wp_query->max_num_pages,
\'current\' => $current,
\'show_all\' => false,
\'end_size\' => $endsize,
\'mid_size\' => $midsize,
\'type\' => $type,
\'prev_text\' => \'<<\',
\'next_text\' => \'>>\'
);
if( $wp_rewrite->using_permalinks() )
$pagination[\'base\'] = user_trailingslashit( trailingslashit( remove_query_arg( \'s\', get_pagenum_link( 1 ) ) ) . \'page/%#%/\', \'paged\' );
if( !empty($wp_query->query_vars[\'s\']) )
$pagination[\'add_args\'] = array( \'s\' => get_query_var( \'s\' ) );
return paginate_links( $pagination );
}