Advertisement
Guest User

Untitled

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