Last active
September 21, 2015 12:48
-
-
Save borantula/5589153b2a235d8ea79f to your computer and use it in GitHub Desktop.
Bootstrap Pagination for WordPress
This file contains hidden or 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
function wp_bootstrap_pagination( $wp_query = false ) { | |
if($wp_query == false) { | |
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' => '← Önceki Sayfa', | |
'next_text' => 'Sonraki Sayfa →', | |
)); | |
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>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment