我正在尝试使用pagination\\u links()将分页添加到WordPress查询中,但是我没有收到返回的第1页链接和上一页链接的链接?其他链接将分页查询字符串添加到URL,然后将您重定向到/page/3/例如。不确定是否需要更新下面的查询以添加这些URL而不是查询字符串?
有人能看到下面的内容有什么问题吗?我如何才能使分页链接正确?
如有任何建议和帮助,将不胜感激。
Query & Pagination:
$posts_per_page = get_option(\'posts_per_page\');
$paged = ( get_query_var( \'paged\' ) ) ? absint( get_query_var( \'paged\' ) ) : 1;
$args = array(
\'posts_per_page\' => $posts_per_page,
\'post_type\' => \'post\',
\'paged\' => $paged,
);
$articles = new WP_Query( $args );
$args = array(
\'base\' => \'%_%\',
\'format\' => \'?paged=%#%\',
\'current\' => max( 1, get_query_var(\'paged\') ),
\'total\' => $wp_query->max_num_pages,
\'show_all\' => false,
\'end_size\' => 1,
\'mid_size\' => 1,
\'prev_next\' => true,
\'prev_text\' => \'<span class="icon icon-arrow-left" aria-hidden="true"></span><span class="sr-only">Previous</span>\',
\'next_text\' => \'<span class="icon icon-arrow-right" aria-hidden="true"></span><span class="sr-only">Next</span>\',
\'type\' => \'plain\',
\'add_args\' => false,
\'add_fragment\' => \'\',
\'before_page_number\' => \'\',
\'after_page_number\' => \'\'
);
echo paginate_links( $args );
Returned HTML:
<div class="pagination">
<a class="prev page-numbers" href=""><span class="icon icon-arrow-left" aria-hidden="true"></span><span class="sr-only">Previous</span></a>
<a class="page-numbers" href="">1</a>
<span aria-current="page" class="page-numbers current">2</span>
<a class="page-numbers" href="?paged=3">3</a>
<a class="next page-numbers" href="?paged=3"><span class="icon icon-arrow-right" aria-hidden="true"></span><span class="sr-only">Next</span></a>
</div>