I'd like to be able to display the number of posts per page and the total number of posts. This question (Show number of posts AND number on current page) was previously asked and a solution provided by karpstrucking:
global $wp_query; $page = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $ppp = get_query_var('posts_per_page'); $end = $ppp * $page; $start = $end - $ppp + 1; $total = $wp_query->found_posts; echo "Showing posts $start through $end of $total total.";
This works really well (thanks karpstrucking), but there is an issue with the last page; if, for example, your pages are set to show 10 posts per page, and there are 23 posts in total, the pages will show:
- Showing posts 1 - 10 of 23
- Showing posts 11 - 20 of 23
- Showing posts 21 - 30 of 23
Some sort of conditional required, but unfortunately I really don't know where to start.
Any help hugely appreciated.