I’ve created a custom plugin page. On this page, I list posts using wp_query(). It works fine. I want to add pagination, but it doesn’t work, even when I’m using the code provided within codex:
<?php
// set the "paged" parameter
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// the query
$the_query = new WP_Query( 'posts_per_page=2&paged=' . $paged );
if ( $the_query->have_posts() ) :
// the loop
while ( $the_query->have_posts() ) : $the_query->the_post();
the_title();
endwhile;
// next_posts_link() usage with max_num_pages
next_posts_link( 'Older Entries', $the_query->max_num_pages );
previous_posts_link( 'Newer Entries' );
// clean up after the query and pagination
wp_reset_postdata();
else:
echo 'Sorry, no posts matched your criteria.';
endif; ?>
When clicking on the pagination link, it loads up new page with the same posts. Why is this not working in the wp-admin area?