weblizar_pagination

The Enigma weblizar pagination function.

Description

weblizar_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( 'weblizar_pagination' ) ) { 
  2. require_once '/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 = weblizar_pagination($pages, $range); 
  12.  

Defined (1)

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

/functions.php  
  1. function weblizar_pagination($pages = '', $range = 2) 
  2. {  
  3. $showitems = ($range * 2)+1;  
  4.  
  5. global $paged; 
  6. if(empty($paged)) $paged = 1; 
  7.  
  8. if($pages == '') 
  9. global $wp_query; 
  10. $pages = $wp_query->max_num_pages; 
  11. if(!$pages) 
  12. $pages = 1; 
  13. }  
  14.  
  15. if(1 != $pages) 
  16. echo "<div class='enigma_blog_pagination'><div class='enigma_blog_pagi'>"; 
  17. if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>"; 
  18. if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>"; 
  19.  
  20. for ($i=1; $i <= $pages; $i++) 
  21. if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) 
  22. echo ($paged == $i)? "<a class='active'>".$i."</a>":"<a href='".get_pagenum_link($i)."'>".$i."</a>"; 
  23.  
  24. if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";  
  25. if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>"; 
  26. echo "</div></div>";