Created
March 19, 2012 16:21
-
-
Save sloped/2117898 to your computer and use it in GitHub Desktop.
Bootstrap Paging and Wordpress
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 Twitter Bootstrap | |
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 '<div class="pagination">'; | |
echo '<ul>'; | |
if($total_pages > 3) { | |
if($current_page > 1) echo '<li class="last"><a href="' . get_bloginfo('url') . '/posts/page/1/?"><<</a></li>' ; | |
if($current_page > 1) echo '<li class="previous"><a href="' . get_bloginfo('url') . '/posts/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') . '/posts/page/' . $count . '/?">' . $count . '</a></li>' ; | |
else echo '<li class="inactive"><a href="' . get_bloginfo('url') . '/posts/page/' . $count . '/?">' . $count . '</a></li>' ; | |
} | |
if($total_pages > 3) { | |
if($current_page < $total_pages) echo '<li class="next"><a href="' . get_bloginfo('url') . '/posts/page/' . $next_page . '/?pp=1">></i></a></li>' ; | |
if($current_page < $total_pages) echo '<li class="last"><a href="' . get_bloginfo('url') . '/posts/page/' . $total_pages . '/?pp=1">>></a></li>' ; | |
} | |
?> | |
</ul> | |
</div> | |
<?php | |
} |
Do you know how this could be modified for Bootstrap 4?
https://v4-alpha.getbootstrap.com/components/pagination/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's good but the last page doesn't show dots on the right place
Correction: