Advertisement
keha76

WP Paginate Function

Sep 4th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. function keha76_pagination()
  2. {
  3.     global $wp_query;
  4.  
  5.     $total_pages = $wp_query->max_num_pages;
  6.  
  7.     if( $total_pages > 1 )
  8.     {
  9.         $current_page = max( 1, get_query_var('paged') );
  10.         echo '<nav id="pagination" role="navigation">';
  11.         echo paginate_links(
  12.             array(
  13.                     'base'      => get_pagenum_link(1) . '%_%',
  14.                     'format'    => '/page/%#%',
  15.                     'current'   => $current_page,
  16.                     'total'     => $total_pages,
  17.                     'end_size'  => 2,
  18.                     'mid_size'  => 2,
  19.                     'prev_text' => __( '&larr; Prev' ),
  20.                     'next_text' => __( 'Next &rarr;' )
  21.                 )
  22.         );
  23.         echo '</nav>';
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement