Pagination only displaying first page with custom loop/wp_query
-
Apologies if this has been answered elsewhere but nothing I turned up was useful for this problem.
I have a custom loop that’s pulling in posts from various different post types. This is everything in my loop before the content…
<?php $paged = ( get_query_var('page') ) ? get_query_var('page') : 1; $query_args = array( 'post_type' => array ('post' , 'reviews' , 'trailer' , 'feature'), 'posts_per_page' => 3, 'paged' => $paged ); $the_query = new WP_Query( $query_args ); ?> <?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
And this is my current pagination set up…
<?php if ($the_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?> <nav class="prev-next-posts"> <div class="prev-posts-link"> <?php echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages ); // display older posts link ?> </div> <div class="next-posts-link"> <?php echo get_previous_posts_link( 'Newer Entries' ); // display newer posts link ?> </div> </nav> <?php } ?>
The ‘Older Entries’ link shows up but doesn’t actually link to any older posts.
I have tried various different ways to add numbered pagination and couldn’t get that working at all, even with WP-PageNavi plugin so I’ve reverted back to the default pagination but still no luck.
Any help would be much appreciated.
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Pagination only displaying first page with custom loop/wp_query’ is closed to new replies.