Advertisement
keha76

WordPress Pagination

Mar 6th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. /**
  2.  * Pagination
  3.  *
  4.  * @return html
  5.  * @since v1.02
  6.  */
  7. function keha76_pagination( $args = array() ) {
  8.    
  9.     global $wp_query;
  10.  
  11.     $current = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  12.    
  13.     if ( get_option('permalink_structure') ) {
  14.         $format = 'page/%#%';
  15.     } else {
  16.         $format = '?paged=%#%';
  17.         if ( !is_home() ) {
  18.             $format = '&paged=%#%';
  19.         }
  20.     }
  21.  
  22.     if ( $wp_query->max_num_pages > 1 ) {
  23.  
  24.         $defaults = array(
  25.             'base'         => get_pagenum_link( 1 ) . '%_%',
  26.             'format'       => $format,
  27.             'total'        => $wp_query->max_num_pages,
  28.             'current'      => $current,
  29.             'show_all'     => false,
  30.             'end_size'     => 2,
  31.             'mid_size'     => 0,
  32.             'prev_next'    => true,
  33.             'prev_text'    => __( '« Newer', 'keha76-blank' ),
  34.             'next_text'    => __( 'Older »', 'keha76-blank' ),
  35.             'type'         => 'plain',
  36.             'add_args'     => false,
  37.             'add_fragment' => ''
  38.         );
  39.  
  40.         $args = wp_parse_args( $args, apply_filters( 'keha76_paginate_links', $defaults ) );
  41.  
  42.         echo paginate_links( $args );
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement