Codes below will show you the how to get the current number of post shows from and to results in a page.
Example :
Showing 01 – 10 post of blog category
Showing 11 – 20 post of blog category
Showing 21 – 29 post of blog category
/*--------------------------------------------------------------------- * $current_page_number default is 1. Example : page number 3 http://site.com/category/blog/page/2/ page number 3 http://site.com/category/blog/page/3/ * $post_per_page is the number of post displayed in a blog category. Example : 5 per page. 10 per page. 15 per page. * $all_post is a overall total number of post under blog category. Example : we 23 post in blog category. $all_post will return you the 23 post. we 33 post in blog category. $all_post will return you the 33 post. ---------------------------------------------------------------------*/ $page = $current_page_number * $post_per_page; if( $current_page_number > 1 ){ $results_from = ( $post_per_page * ( $current_page_number - 1 ) ) + 1; }else{ $s_from = $current_page_number; } if( $page > $all_post ){ $results_to = $all_post; }else{ $results_to = $post_per_page * $current_page_number; }
Leave a Reply