Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2013
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <?php
  2. /*-----------------------------------------------------------------------------------*/
  3. /*  PAGINATION
  4. /*-----------------------------------------------------------------------------------*/
  5. # Pagination code by Kriesi (http://www.kriesi.at).
  6.  
  7. function pagination($pages = '', $range = 2){
  8.  
  9.     $showitems = ($range * 2)+1;  
  10.  
  11.     global $paged;
  12.     if(empty($paged)) $paged = 1;
  13.  
  14.     if($pages == '') {
  15.         global $wp_query;
  16.         $pages = $wp_query->max_num_pages;
  17.        
  18.         if(!$pages) {
  19.             $pages = 1;
  20.         }
  21.        
  22.     }  
  23.  
  24.     if(1 != $pages) {
  25.         echo "<div class='pagination'>";
  26.         if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'><span>&laquo;</span></a>";
  27.         if($paged > 1) echo "<a href='".get_pagenum_link($paged - 1)."'><span>&larr; ". __("Предыдущая", "raw_theme") ."</span></a>";
  28.  
  29.         for ($i=1; $i <= $pages; $i++) {
  30.             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
  31.                 echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' ><span>".$i."</span></a>";
  32.             }
  33.         }
  34.  
  35.         if ($paged < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'><span>". __("Следующая", "raw_theme") ." &rarr;</span></a>";  
  36.         if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'><span>&raquo;</span></a>";
  37.         echo "</div>\n";
  38.     }
  39. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement