Is there a way to know the total number of posts before the loop starts? I’m thinking in use two loops. The first will do the counting, while the second one will handle the content. However, I don’t think this approach is ‘elegant’. Any other solutions?
Leave a Reply
You must be logged in to post a comment.
functions.php:
index.php:
The number of all posts for a given query is in
$GLOBALS['wp_query']->found_posts
.The number of all posts for just the page you are seeing is in
$GLOBALS['wp_query']->post_count
.To see all available variables test it with: