Skip to content

Instantly share code, notes, and snippets.

@aalimran07
Created January 4, 2018 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aalimran07/e458f4f8ec1901879a493607a7b938e5 to your computer and use it in GitHub Desktop.
Save aalimran07/e458f4f8ec1901879a493607a7b938e5 to your computer and use it in GitHub Desktop.
/*
* custom pagination with bootstrap .pagination class
* source: http://www.ordinarycoder.com/paginate_links-class-ul-li-bootstrap/
*/
function david_post_pagination($echo = true)
{
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,
'type' => 'array',
'prev_next' => true,
'prev_text' => '<i class="fa fa-angle-left" aria-hidden="true"></i>',
'next_text' => '<i class="fa fa-angle-right" aria-hidden="true"></i>',
));
if (is_array($pages)) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
$pagination = '<ul class="pagination">';
foreach ($pages as $page) {
$pagination .= "<li>$page</li>";
}
$pagination .= '</ul>';
if ($echo) {
echo $pagination;
} else {
return $pagination;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment