Replace WP Next & Previous post with better Pagination
Replace your typical next and previous pagination ie:
1 2 3 4 5 6 7 8 |
<?php if ($wp_query->max_num_pages > 1) : ?> <nav class="post-nav"> <ul class="pager"> <li class="previous"><?php next_posts_link(__('← Older posts', 'roots')); ?></li> <li class="next"><?php previous_posts_link(__('Newer posts →', 'roots')); ?></li> </ul> </nav> <?php endif; ?> |
with the example as follows to create better pagination. PHP
1 2 3 4 5 6 7 8 9 |
<?php global $wp_query; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages ) ); ?> |