Pagination always only showing two pages?
-
I’ve created a paginated list of terms for a custom taxonomy, but the output for the page navigation buttons is not showing correctly. No matter how many posts per page I set, it always outputs two pages.
So with 6 posts and set to 6 per page, I see two pages, the second one blank. With 6 posts and 2 per page I see two pages, and there is no third page.
Can anyone see why this might be?
$posts_per_page = 6; $page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $offset = ( $page - 1 ); $categories = get_terms('prints_cat'); for( $i = $offset * $posts_per_page; $i < ( $offset + 1 ) * $posts_per_page; $i++ ) { $category = $categories[$i]; echo '<div class="cat-preview"><a href="'; echo get_term_link($category->slug, 'prints_cat'); echo '"><h2>'; echo $category->name; echo '</h2></a></div>'; } unset( $category ); custom_page_navi();
And the code for my
custom_page_navi()
function:function custom_page_navi() { global $wp_query; $bignum = 999999999; if ( $wp_query->max_num_pages <= 1 ) return; echo '<nav class="pagination">'; echo paginate_links( array( 'base' => str_replace( $bignum, '%#%', esc_url( get_pagenum_link($bignum) ) ), 'format' => '', 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages, 'prev_text' => 'Prev', 'next_text' => 'Next', 'type' => 'list', 'show_all' => false, 'end_size' => 2, 'mid_size' => 0 ) ); echo '</nav>'; }
- The topic ‘Pagination always only showing two pages?’ is closed to new replies.