I'm trying to find out whether there is more than one page of posts (I've set my posts per blog page to 5 in the reading settings) in a custom category template.

I would think the global query would have the total number of pages as a property but I can't find the call to it.

2 Answers 2

global $wp_query;
echo $wp_query->max_num_pages;

This shows the number of pages for the current query. If you want to determine the actual number of posts found by the current query, you may use $wp_query->found_posts

Source:- http://codex.wordpress.org/Class_Reference/WP_Query


To this day, Mridul Aggarwal answer is not only valid, but vital to use the_posts_pagination() function in some loops scenarios

global $wp_query;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.