functions.php:
function wpse8170_get_posts_count() {
global $wp_query;
return $wp_query->post_count;
}
index.php:
if (have_posts()) :
echo '<h1>' . wpse8170_get_posts_count() . ' Posts Found</h1>';
while ( have_posts() ) :
the_post();
//...
endwhile;
endif;
Related Posts:
- How to get URL of current page displayed?
- Getting only direct child pages in WordPress with get_pages
- Query multiple custom post types in single loop
- What is This esc_html_e() i wordpress php?
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Date of last blog update for specific authors only?
- View tag description on page
- Making list of posts with chosen description
- Filter loop by ‘price’ with meta_query
- Get current_post in reverse order with pagination
- PHP for loop not working as intended
- How fix error in the WordPress loop?
- what’s the syntax for if the image exists get the image?
- Adding custom PHP to existing loop in Genesis
- How to Pass Current Taxonomy Terms into new WP_Query?
- Problems with the WordPress loop [closed]
- Add div after every 4 posts then every 2 posts for a responsive loop
- how to remove replicating a tag inside loop?
- My query keeps looping infinitely ! how to stop it?
- Efficient way of querying for a “fallback” post?
- Insert div after every three posts in home.php [duplicate]
- WordPress while loop with aphabetic counting like one, two, three
- Display product attributes for current product
- Retrieving specific images from Media Library
- For each 3 posts, show a different post type
- Div Missing In Custom Loop Query
- Add post class in custom loop (WP_QUERY)
- Loop 1 user randomly
- Create a hierarchical loop at predefined markup requirements
- enumerating custom taxonomies?
- Loop returns more items than exist?
- Using page template to fetch posts in page
- Modify category archive page loop on functions.php
- Custom Taxonomy Link Text Echo Name Not Slug
- WP_Post is not from correct array
- Post formating on Home page
- divide custom field values in div every two values
- Create Customization Controls from Array
- Adding unique marketing messages between certain products whilst using isotope/Infinite Scroll
- I want my wordpress loop to only display posts of the standard format
- Automatically create a loop for post ID
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Limit ads appearing more than three times
- Problems With Query and/or Template Part and/or PHP
- Two loops in one function
- ACF loop and php formatting
- How to display thumbnail if post is assigned one otherwise not
- How to have post count after each listed category
- Inserting A Feed and Sidebar into an HTML Page
- How can I put a custom field as the link of a button shortcode?
- Pagination on Custom Loop
- Pagenav Not appearing on custom Template
- Error trying import one category on page
- What is the best way to get the first few post from WordPress in different divs using a loop?
- why is this content-template not showing any of my blog-entries?
- Transient Loop Not working as expected
- the_post_thumbnail unless video id is added
- Advanced Taxonomy query, with 3 post types
- Remove the_content From Loop
- Trying to display ads on only a third of posts in a loop. Keep getting Error 500?
- Custom Meta Box If Else Statement
- Custom single.php files for different post formats
- Adding if statement to content for homepage
- Tables not showing divs and loop/php items
- How to call the_author_meta and make it work?
- Troubleshooting “loopback requests that take too long”
- Why does a meta_query break this WP_Query?
- Conditional in foreach loop is outputting content twice
- WordPress post pagination on custom template not working
- Alternative loop syntax error [closed]
- Pagination in category.php not functioning
- is there away to hide php code in wordpress not to show in PAGES
- Implement “No related posts for this entry” into the loop?
- For each loop will not append to the_content hook
- Excerpt all post content Content Same Size without word cutting off
- How to handle parent and child pages?
- Options.php loop won’t show!
- Loop on a wordpress Page instead of content coming from the WP text editor
- How do I remove blog entries from home page Twenty Eleven child theme?
- How to create a loop where loop changes every post?
- How to create a loop that will display one post and stop?
- Woocommerce linking variations
- Help with if/else loop [closed]
- Pagination not working properly
- $_html is empty when var dumped
- I want to show image from custom field image on my custom page template
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- Saving meta box data from selected option’s value in database is not working
- Count the number of matching post names in foreach loop
- How do I exclude the current post from the upcoming post query
- How do I display WooCommerce products in my query to rows of 3?
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress
- How to show correct td of table tags in wp_query loop
- fetch from an external api call and display results in page
- How to pull through page title depending on which radio button is selected on the specific page?
- Add More Featured Data Not Sending to Database
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?
- When a foreach loop is used multiple times in blocks, is there a way to ensure a variable always has a unique value?
- Custom theme on multisite has issues with standard loop output
- How to get the post title inside a custom block in a loop? block.js