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
Related Posts:
- Pagination when using wp_query?
- Post_count only shows the number of results per page
- Pagination on a WP_query not showing navigation links
- How to paginate wordpress [gallery] shortcode?
- paginate_links ignore my format
- Combining two wordpress queries with pagination is not working
- How to paginate attachments in a secondary query as gallery?
- next_posts_link not working for loop called with ajax
- Why does pagination always break when used on any form of a home page?
- Pagination shows 404 after a certain number of pages
- Pagination not working for Custom search form & custom result template
- How to adjust found_posts so that it accounts for offset and pagination
- Pagination broken when merging search results with additional WP_Query
- pagination doesn’t show up for custom post type
- Pagination causes error 404 when used with front-page.php
- Paginated pages are showing correct content but pagination links are not
- Query with pre_get_posts to get pagination
- Best Practice For Querying Grandchildren?
- Pagination is not working using WP_Query
- Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?
- Add custom search results to main WP search [duplicate]
- How to bring specific post to front of wordpress loop?
- Pagination for custom query on single.php
- Pagination doesn’t work in custom page template [duplicate]
- Intentionally exceed max_num_pages on main query without getting 404?
- WP_QUERY loop, offset in the arguments and the paginate_links – can these work together?
- Too many posts cause slow load when paginating
- How to output different posts per page?
- Multiple WP_Query loops with Pagination Not Working
- Posts loop with pagination on a single post page
- Custom pagination with WP_Query generating 404 error
- Pagination working everywhere but the index page
- Offset Page Loops and Pagination
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- The pagination on index.php doesn’t work on a first page
- Get pagination working for custom loops within page templates
- pagination with ‘no_found_rows’ => true,
- how to handle multiple ajax wordpress queries?
- WordPress pagination not working using WP_Query
- posts_per_page not working for first page of pagination
- Pagination links missing for first link (1) and previous button? How to get pagination links to work?
- Pretty urls for custom pagination
- Custom post type archive pagination query issue
- paged variable not working for category/custom post archive
- WordPress Blog Posts with Pagination inside a Page/Post
- Pagination only won’t work in author template
- wp query error while paging the posts
- new WP_Query messes up pagination
- Display single most recent post in category on every page of category archive
- Pagination works in custom query loop but it doesn’t work in shortcode
- “paged” in WP_Query returns 0 posts
- Notice thrown when creating numeric pagination on custom query
- Content not displaying on paginated page
- Second loop pagination changes URL, not content
- Custom Homepage Pagination using WP_Query
- filter posts by meta key with pagination
- Adding pagination to sub-wp_query within a singular post page
- Pagination problem by using WP_Query
- Ajax (jquery) wp_query pagination returns -1
- WP_Query and pagination AGAIN?
- Function the_posts_pagination() not compatible with WP_Query arguments
- adding pagination to a foreach loop in wordpress
- Pagination of custom page with custom fields query
- pre_get_posts pagination not working
- Pagination not working on archive.php template?
- Pagination inside the blog page not working
- Pagination on archive.php not working?
- Custom Query Pagination not working on static front page
- WordPress search page pagination displaying but not functional
- pagination functions are not working
- WordPress pagination not returning posts on second page
- Paginated Post List on Front Page
- Problem with custom WP_Query and underlying pagination/posts_per_page
- Pagination in WP_Query?
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- 3 wp_query on one page with pagination for last query
- Custom pagination (Title, date and teaser)
- Archive – Show Page Month Headers
- Query post Pagination Problem
- Add pagination to table generated by wp_query
- Pagination for custom query throws 404 errors on last pages [duplicate]
- Pagination is not working on custom query inside a custom home page template
- Pagination not working in some author pages
- How to add archives (with pagination) to page template?
- No content found on page 2 of pagination with 1 post per page
- What is wrong with this pagination code?
- Ordering Custom WP_Query loop by meta key value with pagination
- Loop being strainge
- Pagination in custom query not working [duplicate]
- paginate_links() on page (shortcode output)
- Multiple loops on index page with sticky post and pagination
- Paginate wp_query while utilizing post__not_in
- Get next post when using pagination with WP_Query?
- Duplicate posts showing up in loop using infinite scroll
- Pagination showing same posts despite changing page
- Pagination with Custom Post Type not working on index.php: I get a 404
- Pagination on custom post type not working
- Search results stuck on page 1
- Pagination only showed when no category is set in wp_query
- taxonomy-{term}.php terms pagination returning 404 after a certain page