Skip to content

Instantly share code, notes, and snippets.

@degt
Last active August 29, 2015 14:02
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 degt/5fd92b510f1a006c8933 to your computer and use it in GitHub Desktop.
Save degt/5fd92b510f1a006c8933 to your computer and use it in GitHub Desktop.
Wordpress Pagination - Bootstrap style
<?php
//Custom pagination
function wp_bootstrap_pagination()
{
global $wp_query;
$big = 999999999;
$current = max(1, get_query_var('paged'));
$paginate = paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => $current,
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_text' => __('« '),
'next_text' => __(' »')
));
if($paginate){
echo '<ul class="pagination">';
foreach($paginate as $page){
if(strpos($page, 'current')){
echo '<li class="active">'.$page.'</li>';
}else{
echo '<li>'.$page.'</li>';
}
}
echo '</ul>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment