×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Eric De Kock
Added: Apr 3, 2017 7:10 AM
Views: 9
Tags: no tags
  1. function bs_pagination() {
  2.     global $wp_query;
  3.  
  4.     $big = 999999999; // need an unlikely integer
  5.  
  6.     $pages = paginate_links(array(
  7.         'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
  8.         'format' => '?paged=%#%',
  9.         'current' => max(1, get_query_var('paged')),
  10.         'total' => $wp_query->max_num_pages,
  11.         'type' => 'array',
  12.     ));
  13.  
  14.     if (is_array($pages)) {
  15.         $paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
  16.         echo '<ul class="pagination">';
  17.  
  18.         foreach ($pages as $page) {
  19.             echo "<li>$page</li>";
  20.         }
  21.  
  22.         echo '</ul>';
  23.     }
  24. }
  25.