Advertisement
Guest User

Untitled

a guest
Aug 31st, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*inserts custom page/post navigation at the bottom of posts */
  2. function blah_pagination($pages = '', $range = 1) {   /* handle pagination for post pages*/
  3.     $showitems = ($range * 1)+1;
  4.     global $paged;
  5.     if(empty($paged)) $paged = 1;
  6.     if($pages == '')  {
  7.         global $wp_query;
  8.         $pages = $wp_query->max_num_pages;
  9.         if(!$pages ) $pages = 1;
  10.     }
  11.     echo '<div class="pagination">';
  12.     if( $pages  != 1 ) {
  13.         echo '<span>Page ' . $paged . ' of ' . $pages . '</span>';
  14.         if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo '<a href="'.get_pagenum_link(1) . '">&laquo; First</a>';
  15.         if($paged > 1 && $showitems < $pages) echo '<a href="'.get_pagenum_link($paged - 1).'">&lsaquo; Previous</a>';
  16.  
  17.         for ($i=1; $i <= $pages; $i++) {
  18.             if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
  19.                  echo ($paged == $i)? '<span class="current">'.$i.'</span>':'<a href="'.get_pagenum_link($i).'"class="inactive">'.$i.'</a>';
  20.             }
  21.         }
  22.     }
  23.  
  24.     if ($paged < $pages && $showitems < $pages) echo '<a href="'.get_pagenum_link($paged + 1).'">Next &rsaquo;</a>';
  25.     if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo '<a href="'.get_pagenum_link($pages).'">Last &raquo;</a>';
  26.     echo "</div>\n";
  27. } //  blah_pagination
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement