Skip to content

Instantly share code, notes, and snippets.

@fomigo
Forked from sloped/paging.php
Created August 20, 2014 08:36
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 fomigo/73f4fdb264c548c1323a to your computer and use it in GitHub Desktop.
Save fomigo/73f4fdb264c548c1323a to your computer and use it in GitHub Desktop.
<?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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment