I am trying to get the current number of posts that will be present in a page.
$wp_query->found_posts will give me the total number of posts in the loop.
get_query_var( 'posts_per_page' ) will tell me the number of posts per page.
get_query_var( 'paged' ) will give me the current page number.
sticky posts seem to not be included in the above.
I can do some maths trying to figure out in what page I am, retrieve the number of posts, and consider the sticky. I could also add a counter in the loop, but I am trying to get the number before the loop is applied in the template (front-end).
Is there some variable in the
$wp_query that I am missing for this goal?
To make it clear this is an example: Total posts from the loop 22. Posts per page 10. 1 sticky post.
- Page 1 should give 11 (10 + 1 sticky).
- Page 2 should give 10.
- Page 3 should give 2.