Answer the question
In order to leave comments, you need to log in
Why is pagination not working?
function pagination() {
global $wp_query;
if ( $wp_query->max_num_pages <= 1 ) return;
$big = 999999999; // need an unlikely integer
$pages = 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,
'type' => 'array',
'prev_text' => ( '<span class="icon icon-back"></span>' ),
'next_text' => ( '<span class="icon icon-back next"></span>' ),
) );
if( is_array( $pages ) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<nav><ul class="pagination">';
foreach ( $pages as $page ) {
echo "<li class='page-item'>$page</li>";
}
echo '</ul></nav>';
}
}
Answer the question
In order to leave comments, you need to log in
And won't work. Use the_posts_pagination()
or the_posts_navigation()
. For customization, you can see the code of these functions
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question