-
-
Save fovoc/7945067 to your computer and use it in GitHub Desktop.
Bootstrap3 style pagination for Shoestrap 3 theme
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 | |
//Use this function to create pagingation links that are styleable with Bootstrap 3 | |
function paging() { | |
global $wp_query; | |
$total_pages = $wp_query->max_num_pages; | |
if ($total_pages > 1){ | |
$current_page = max(1, get_query_var('paged')); | |
$count = 0; | |
$previous_page = $current_page - 1; | |
$next_page = $current_page + 1; | |
echo '<ul class="pagination">'; | |
if($total_pages > 3) { | |
if($current_page > 1) echo '<li class="last"><a href="' . get_bloginfo('url') . '/page/1/?"><<</a></li>' ; | |
if($current_page > 1) echo '<li class="previous"><a href="' . get_bloginfo('url') . '/page/' . $previous_page . '/?"><</i></a></li>' ; | |
} | |
while($count < $total_pages) { | |
$count = $count + 1; | |
if($count == $current_page) echo '<li class="active"><a href="' . get_bloginfo('url') . '/page/' . $count . '/?">' . $count . '</a></li>' ; | |
else echo '<li class="inactive"><a href="' . get_bloginfo('url') . '/page/' . $count . '/?">' . $count . '</a></li>' ; | |
} | |
if($total_pages > 3) { | |
if($current_page < $total_pages) echo '<li class="next"><a href="' . get_bloginfo('url') . '/page/' . $next_page . '">></i></a></li>' ; | |
if($current_page < $total_pages) echo '<li class="last"><a href="' . get_bloginfo('url') . '/page/' . $total_pages . '">>></a></li>' ; | |
} | |
?> | |
</ul> | |
<!-- This is for hidding the default paging --> | |
<style type="text/css">.post-nav { display: none; }</style> | |
<?php | |
} | |
} | |
add_action( 'shoestrap_index_end', 'paging' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment