I doubt you’re going to be able to repurpose WP-PageNavi for this, since you’re not using the built-in queries at all. You should be able to roll pagination yourself, though, and still fall back on some of WordPress’s built-in functionality.
In particular, if your URL matches the pattern /meet-the-team/page/3/, the paged
querystring variable will automatically be filled with 3
. You can use that, then just loop through the correct authors in your list. Here’s a bit of quick code:
<?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="https://wordpress.stackexchange.com/meet-the-team/page/" . ($page_number - 1) . "https://wordpress.stackexchange.com/">Previous page</a>';
}
if ($last_author < $author_count) {
echo '<a href="https://wordpress.stackexchange.com/meet-the-team/page/" . ($page_number + 1) . "https://wordpress.stackexchange.com/">Next page</a>';
}
endif;
?>