Pagenation Custom


$posts_per_page = 9; 
$cat = "news"; 


    $all_data .="<div class='pagenation_wrap'>";
 
	    if (!empty($_GET['offset'])) { 
	    
	    $all_data .="<a href='?offset=0' class='pagenation'><< First</a>";
	    
	    }
	 
	   $call_args['offset'] = $_GET['offset'];
	  
	  
	   $categories      = get_term_by('slug',$cat,'category');
	   $number_in_cat   = $categories->count; 

	   $num_of_pages        = ceil($number_in_cat/$posts_per_page);
	   $offset              = $_GET['offset'];
	   $current_offset      = 0;
	   $display_max_count   = $_GET['offset']/$posts_per_page+$posts_per_page;
	   $display_min_count   = $_GET['offset']/$posts_per_page-$posts_per_page;
	   $current_count       = 0;
	     
	   for($c=1;$c<=$num_of_pages;$c++) {
	       $current_count++;
	       if (empty($current_offset))  { $current="current_pagenation"; }else{ $current=""; }
	       if (!empty($offset)) { if ($current_offset/$offset == 1 ) { $current="current_pagenation"; }else{ $current=""; } }
	       if ($current_count > $display_min_count && $current_count < $display_max_count) {
	       $all_data .="<a href='?offset=$current_offset' class='pagenation $current'>$c</a> | ";
	       }
	       $current_offset = $current_offset + $posts_per_page;
	       $last_offset = $current_offset;
	   }
	
	 
	    $all_data .="<a href='?offset=$last_offset' class='pagenation $current'>Last >></a>";
	    
    $all_data .="</div>";

	return $all_data;

Comments