Created
August 7, 2015 07:43
-
-
Save sonnetmia/eb0514caabb635768f78 to your computer and use it in GitHub Desktop.
Bootstrap pagination Code example
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 | |
function arf_defaultpagination() { | |
global $wp_query; | |
$big = 999999999; | |
$pages = paginate_links(array( | |
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), | |
'format' => '?page=%#%', | |
'current' => max(1, get_query_var('paged')), | |
'total' => $wp_query->max_num_pages, | |
'prev_next' => false, | |
'type' => 'array', | |
'prev_next' => TRUE, | |
'prev_text' => '← Previous', | |
'next_text' => 'Next →', | |
)); | |
if (is_array($pages)) { | |
$current_page = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged'); | |
echo '<ul class="pagination">'; | |
foreach ($pages as $i => $page) { | |
if ($current_page == 1 && $i == 0) { | |
echo "<li class='active'>$page</li>"; | |
} else { | |
if ($current_page != 1 && $current_page == $i) { | |
echo "<li class='active'>$page</li>"; | |
} else { | |
echo "<li>$page</li>"; | |
} | |
} | |
} | |
echo '</ul>'; | |
} | |
} | |
// Use arf_defaultpagination() function inside your query , Normally it placed after end of the while loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment