Skip to content

Instantly share code, notes, and snippets.

@asifsaho
Created September 25, 2015 16:20
Show Gist options
  • Save asifsaho/d189e0d82bab2b9dd02a to your computer and use it in GitHub Desktop.
Save asifsaho/d189e0d82bab2b9dd02a to your computer and use it in GitHub Desktop.
WP:bootstrap paginations
function custom_pagination() {
global $wp_query;
$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,
'prev_next' => false,
'type' => 'array',
'prev_next' => TRUE,
'prev_text' => __('«'),
'next_text' => __('»'),
) );
if( is_array( $pages ) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<ul class="pagination">';
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