Add “showing posts x to x of y” in custom post type paginated loop

All query objects have a few built in vars that can help you display this.

Assuming your custom query object is $query:

  • The total number of posts across all pages is $query->found_posts
  • The total number of posts for the current page is
    $query->post_count
  • The current page number is
    $query->query_vars['paged']
  • The number of posts per page is
    $query->query_vars['posts_per_page']

With that in mind, we can do something like this:

$pagenum = $query->query_vars['paged'] < 1 ? 1 : $query->query_vars['paged'];
$first = ( ( $pagenum - 1 ) * $query->query_vars['posts_per_page'] ) + 1;
$last = $first + $query->post_count - 1;
echo "Showing posts $first - $last of $query->found_posts";

EDIT – If you want to use the above with the main query, change all instances of $query to $wp_query