Skip to content

Instantly share code, notes, and snippets.

@mdjwel
Last active July 21, 2022 17:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdjwel/0e10df5c7ffeea1cc17092ee11b1fd75 to your computer and use it in GitHub Desktop.
Save mdjwel/0e10df5c7ffeea1cc17092ee11b1fd75 to your computer and use it in GitHub Desktop.
Apply Custom ul>li Pagination in WordPress
<?php
function saasland_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',
) );
if( is_array( $pages ) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<ul class="list-unstyled page-numbers shop_page_number">';
foreach ( $pages as $page ) {
echo "<li>$page</li>";
}
echo '</ul>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment