我怀疑您是否能够为此重新调整WP PageNavi的用途,因为您根本没有使用内置查询。不过,您应该能够自己进行分页,并且仍然可以依赖WordPress的一些内置功能。
特别是,如果您的URL与模式/会见团队/页面/3/匹配,则paged
querystring变量将自动填充为3
. 您可以使用它,然后在列表中循环查找正确的作者。下面是一些快速代码:
<?php
$authors_per_page = 5;
$page_number = preg_replace("/[^0-9]/", "", $_GET["paged"]); // don\'t trust querystring vars
if (empty($page_number))
$page_number = 1;
$excluded = "1,2,3,7,20,21"; // To exclude external admin author IDs
$sql = "..."; // SQL unchanged, omitted
$authors = $wpdb->get_results($sql);
if ($authors) :
$author_count = count($authors);
$first_author = ($page_number - 1) * $authors_per_page;
$last_author = min($first_author + $authors_per_page, $author_count);
foreach ($i = $first_author; $i < $last_author; $i++) :
?>
<!-- display author -->
<?php
endforeach;
// show previous and next page links
if ($page_number > 1) {
echo \'<a href="/meet-the-team/page/\' . ($page_number - 1) . \'/">Previous page</a>\';
}
if ($last_author < $author_count) {
echo \'<a href="/meet-the-team/page/\' . ($page_number + 1) . \'/">Next page</a>\';
}
endif;
?>