Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1.  
  2. if (!function_exists()) {
  3.  
  4.     function paginate() {
  5.         global $wp_query, $wp_rewrite;
  6.         $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
  7.  
  8.         $pagination = array(
  9.             'base' => @add_query_arg('page','%#%'),
  10.             'format' => '',
  11.             'total' => $wp_query->max_num_pages,
  12.             'current' => $current,
  13.             'show_all' => true,
  14.             'type' => 'list',
  15.             'next_text' => '»',
  16.             'prev_text' => '«'
  17.             );
  18.  
  19.         if( $wp_rewrite->using_permalinks() )
  20.             $pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
  21.  
  22.         if( !empty($wp_query->query_vars['s']) )
  23.             $pagination['add_args'] = array( 's' => get_query_var( 's' ) );
  24.  
  25.         echo paginate_links( $pagination );
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement