Advertisement
Guest User

pagination.php

a guest
Aug 5th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Custom pagination functions
  4.  *
  5.  * @package WordPress
  6.  * @subpackage Pronto
  7.  * @since Pronto 1.0
  8.  */
  9.  
  10.  
  11. // Numbered pagination
  12. if ( ! function_exists('wpex_pagination') ) {
  13.    
  14.     function wpex_pagination() {
  15.         global $wp_query;
  16.         $total = $wp_query->max_num_pages;
  17.         $big = 999999999; // need an unlikely integer
  18.         if( $total > 1 )  {
  19.              if( !$current_page = get_query_var('paged') )
  20.                  $current_page = 1;
  21.              if( get_option('permalink_structure') ) {
  22.                  $format = 'page/%#%/';
  23.              } else {
  24.                  $format = '&paged=%#%';
  25.              }
  26.             echo paginate_links(array(
  27.                 'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  28.                 'format'    => $format,
  29.                 'current'   => max( 1, get_query_var('paged') ),
  30.                 'total'     => $total,
  31.                 'mid_size'  => 4,
  32.                 'in_same_cat'   => true,
  33.                 'type'      => 'list',
  34.                 'prev_text' => '<i class="fa fa-angle-left"></i>',
  35.                 'next_text' => '<i class="fa fa-angle-right"></i>',
  36.              ));
  37.         }
  38.     }
  39.    
  40. }
  41.  
  42.  
  43. // Custom page entry pagination function
  44. if ( !function_exists('wpex_pagejump') ) {
  45.    
  46.     function wpex_pagejump($pages = '', $range = 4) {
  47.        
  48.          $showitems = ($range * 2)+1;
  49.          global $paged;
  50.          if ( empty($paged) ) $paged = 1;
  51.          
  52.          if ( $pages == '' ) {
  53.              global $wp_query;
  54.              $pages = $wp_query->max_num_pages;
  55.              if(!$pages) {
  56.                  $pages = 1;
  57.              }
  58.          }  
  59.      
  60.          if ( 1 != $pages ) {
  61.             echo '<div class="post-navigation clr"><div class="alignleft">';
  62.             previous_posts_link( '&larr; ' . __('Newer Posts', 'wpex' ) );
  63.             echo '</div><div class="alignright">';
  64.             next_posts_link( __('Older Posts', 'wpex' ) .' &rarr;' );
  65.             echo '</div></div>';
  66.          }
  67.          
  68.     }
  69.  
  70. }
  71.  
  72.  
  73. // Infinite Scroll
  74. if ( !function_exists( 'wpex_infinite_scroll' ) ) {
  75.    
  76.     function wpex_infinite_scroll( $type = 'standard' ) {
  77.        
  78.         // Output pagination HTML
  79.         $output = '';
  80.         $output .= '<div class="infinite-scroll-nav clr">';
  81.             $output .= '<div class="alignleft newer-posts">';
  82.                 $output .= get_previous_posts_link('&larr; '. __( 'Newer Posts', 'wpex' ) );
  83.             $output .= '</div>';
  84.             $output .= '<div class="alignright older-posts">';
  85.                 $output .= get_next_posts_link( __( 'Older Posts', 'wpex' ) .' &rarr;');
  86.             $output .= '</div>';
  87.         $output .= '</div>';
  88.         echo $output;
  89.     }
  90.    
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement