我有如下所示的代码来分页我成功完成的Wordpress自定义查询代码。我遇到的问题是在页面上我有一些链接来按不同的字段订购帖子。
点击这些链接之后,分页链接就出错了,分页部分会添加到最后,链接最终会像http://ideation/pagination/?c=General+Improvement/page/2/那样显示为http://ideation/pagination/page/2/?c=General+Improvement
我的分页代码如下,任何方向都会受到赞赏。
<?php
global $wp_rewrite, $wp_query, $max_page, $page;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
$pagination = array(
'base' => @add_query_arg('page', '%#%'),
'format' => '/page/%#%',
'total' => $max_num_pages,
'current' => $current,
'prev_text' => __('PREV'),
'next_text' => __('NEXT'),
'end_size' => 1,
'mid_size' => 2,
'show_all' => false,
'type' => 'list'
);
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')
);
echo paginate_links($pagination);
?>