The query object contains the member var post_count
which will give you the number of posts on the current page:
$wp_query->post_count;
Also, for the total number of posts for the query (across all pages):
$wp_query->found_posts;
and the number of pages in the query:
$wp_query->max_num_pages;
Related Posts:
- White screen of death on index.php page 3 and above?
- wp_nav_menu(), how to change class?
- Add custom classes to anchor in wp_nav_menu
- Get ‘page’ number with infinite scroll
- Get 10 posts from a WP_Query. If less than 10, get the remainder from elsewhere
- Strict Standards Error bootstrap navwalker
- Why doesn’t /2013/01/ properly return January’s archives in archive.php?
- Strategy to get post meta for use outside the loop
- How to add menu support to a theme?
- Grab the first paragraph of each post
- Single Page WordPress Theme – Using page templates
- How to add a section to the menus configuration, offering hard coded items?
- A two column loop with one lead post
- Change loop order via form or link (jquery, not URL)
- Extend walker – navigation, adding data attribute to a tag
- First post of each category
- Is there any need to use both wp_reset_postdata and wp_reset_query together?
- query posts in wordpress
- Displaying wp menus by name without using theme locations
- Getting Permalink within the loop
- the_content() in single-{post-type}.php problem
- Why does this loop only work on the homepage?
- how to change WordPress menu markup/classes
- Setting hero/splash section as a blog post
- posts_nav_link(); not showing up on static pages
- Setting a Default ‘Theme Location’ When Creating a Menu
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Finding Page Template and Displaying Content
- How WordPress converts URL to $query_string
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- How to add categories to wp_list_pages()
- Link won’t show using the_permalink();
- Some doubts about how to show posts in a custom theme?
- Force index.php have_posts() loop to exit if no sticky posts found
- .sub-menu or .children?
- Arguments ignored/markup changed in wp_nav_menu if no menu is selected
- show a post from a specific post format
- paged > max_num_pages won’t throw 404
- My Admin bar covers my sticky navbar [closed]
- WordPress is adding margins and padding to my custom menu?
- Displaying recent post excerpts on static front page
- Primary navigation menu & footer not showing in category / tag page
- Limit Loop to 5 Posts?
- How can I sort my loop based on meta data, using a form?
- List categories of a post hierarchically?
- Exclude parent categories from the_category() within the loop
- get_the_terms() returning wrong results inside of loop
- Show only pages you are author of
- Add class every 4 post like , class_1, class_2, class_3, class_4 and class_1, class_2, class_3, class_4
- Programatically Created Menu not Editable in Dashboard
- Does single webpage do not need navigation to create a slug in permalink?
- How do I make my terms for each product display via foreach loop? (woocommerce)
- WordPress Insert ads after every 5th post
- 3 Level Menu Navigation (3rd Level not displaying)
- WordPress theme files Organization
- Infinite loop when nesting have_posts()
- Local variable name in setup_postdata()
- Loop is breaking my theme. How can I fix?
- How can I show a custom WordPress menu anywhere I want on my website?
- my ajax wont sent the data, please correct my code
- Show all menu levels except top level. How to exclude top level of a menu?
- WordPress Menu item > Sub menu Class update
- Move the social media icons to the left of a WordPress nav menu for Soledad child Theme
- control posts order by select option
- Problem with Displaying Custom Theme Page’s Content
- Need help with adding custom wordpress menu and sub-menu
- Why content is not adding for each blog post
- How to achieve this navigation style in wordpress navigation
- Fallback dosen’t work when not using ‘menu’ attribute
- Best way to allow for extended use of WordPress functions inside single.php
- How to add drop symbol to parent nav items which have child
- WordPress 3.9 two menus in same position?
- Conditional loop based on current page
- Loop through all posts, show attachment if there
- Strict Standards Error bootstrap navwalker
- Suppress the_content filter in a nested loop
- Tags interfering with next_post_link();
- Simple loop with shortcode rendering problem
- How get the 10 most viewed pages (not post)
- How to close open divs in post loop
- The normal loop with different styles doesn’t work in search.php
- Checking conditionals
- issue displaying variations in custom template using WPeC 3.8.9.2
- All post ids are the same after this query but rewind_posts() does not seem to work here?
- Not Found when using activity stream as front page with BuddyPress
- Why does the first loop take arguments from the second loop?
- How to make navigation a list without a plugin? [duplicate]
- have_posts() return false on single post
- How to defeat “Blog pages show at most __ posts” setting in the loop?
- Display Page featured Image as well as Posts featured Image
- can’t add EVENT LISTENER to a element
- WordPress Loop with Custom Post Type for Bootstrap Accordion [closed]
- Why am I getting posts back when I shouldnt
- Fatal error: Call to undefined function the_posts_navigation()
- Is there any reason that other theme elements (such as nav menus) shouldn’t be within the loop?
- Bootstrap 4 mobile menu not working for WordPress Development
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- wp_nav_menu_items callback not triggered
- Custom loop menu is not working
- Disable interactivity for core navigation