Advertisement
niammuddin

fungsi pagination wordpress

Jul 27th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.37 KB | None | 0 0
  1. <?php
  2. // fungsi pagination
  3. function kriesi_pagination($pages = '', $range = 2)
  4. {
  5.      $showitems = ($range * 2)+1;
  6.  
  7.      global $paged;
  8.      if(empty($paged)) $paged = 1;
  9.  
  10.      if($pages == '')
  11.      {
  12.          global $wp_query;
  13.          $pages = $wp_query->max_num_pages;
  14.          if(!$pages)
  15.          {
  16.              $pages = 1;
  17.          }
  18.      }
  19.  
  20.      if(1 != $pages)
  21.      {
  22.          echo "<div class='pagination'>";
  23.          if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a rel='nofollow' href='".get_pagenum_link(1)."'>&laquo;</a>";
  24.          if($paged > 1 && $showitems < $pages) echo "<a rel='nofollow' href='".get_pagenum_link($paged - 1)."'>&lsaquo;</a>";
  25.  
  26.          for ($i=1; $i <= $pages; $i++)
  27.          {
  28.              if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
  29.              {
  30.                  echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a rel='nofollow' href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
  31.              }
  32.          }
  33.  
  34.          if ($paged < $pages && $showitems < $pages) echo "<a rel='nofollow' href='".get_pagenum_link($paged + 1)."'>&rsaquo;</a>";
  35.          if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo "<a rel='nofollow' href='".get_pagenum_link($pages)."'>&raquo;</a>";
  36.          echo "</div>\n";
  37.      }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement