WP_Query pagination not working in admin area

Milo noted that there is no $wp_query object in wp-admin page, so we can get $paged via:

$paged = ( $_GET['paged'] ) ? $_GET['paged'] : 1;

Now that we have $paged, we can code our own pagination. I will demonstrate how in its very simplest form.

First let’s get maximum pagination pages:

$max_pages = $the_query->max_num_pages;

Then calculate the next page:

$nextpage = $paged + 1;

Finally, let’s create our pagination link. We do a basic if statement checking if $max_pages is greater than $paged:

if ($max_pages > $paged) {
    echo '<a href="admin.php?page=plugin-page.php&paged='. $nextpage .'">Load More Topics</a>';
}

It is as simple as that.

Update

To enable previous page you can simply add:

$prevpage = max( ($paged - 1), 0 ); //max() will discard any negative value
if ($prevpage !== 0) {
   echo '<a href="admin.php?page=plugin-page.php&paged='. $prevpage .'">Previous page</a>';
}