inkthemes_pagination

Pagination.

Description

inkthemes_pagination( (string) $pages = '', (int) $range = 2 ); 

Parameters (2)

0. $pages — Optional. (string) => ''
The pages.
1. $range — Optional. (int) => 2
The range.

Usage

  1. if ( !function_exists( 'inkthemes_pagination' ) ) { 
  2. require_once '/functions/inkthemes-functions.php'; 
  3.  
  4. // The pages. 
  5. $pages = ''; 
  6.  
  7. // The range. 
  8. $range = 2; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = inkthemes_pagination($pages, $range); 
  12.  

Defined (1)

The function is defined in the following location(s).

/functions/inkthemes-functions.php  
  1. function inkthemes_pagination($pages = '', $range = 2) { 
  2. $showitems = ($range * 2) + 1; 
  3. global $paged; 
  4. if (empty($paged)) 
  5. $paged = 1; 
  6. if ($pages == '') { 
  7. global $wp_query; 
  8. $pages = $wp_query->max_num_pages; 
  9. if (!$pages) { 
  10. $pages = 1; 
  11. if (1 != $pages) { 
  12. echo "<ul class='paging'>"; 
  13. if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) 
  14. echo "<li><a href='" . get_pagenum_link(1) . "'>«</a></li>"; 
  15. if ($paged > 1 && $showitems < $pages) 
  16. echo "<li><a href='" . get_pagenum_link($paged - 1) . "'>‹</a></li>"; 
  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) ? "<li><a href='" . get_pagenum_link($i) . "' class='current' >" . $i . "</a></li>" : "<li><a href='" . get_pagenum_link($i) . "' class='inactive' >" . $i . "</a></li>"; 
  20. if ($paged < $pages && $showitems < $pages) 
  21. echo "<li><a href='" . get_pagenum_link($paged + 1) . "'>›</a></li>"; 
  22. if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) 
  23. echo "<li><a href='" . get_pagenum_link($pages) . "'>»</a></li>"; 
  24. echo "</ul>\n";