Last active
August 29, 2015 14:02
-
-
Save degt/5fd92b510f1a006c8933 to your computer and use it in GitHub Desktop.
Wordpress Pagination - Bootstrap style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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