WP_Query seems to set two variables, $posts and $post_count when running(according to the source over at http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/query.php ). You can access these two and work something out to figure out if you’re in the last three posts.
var_dump those two to see if there’s a count, add in your own counter and you should be good to go.
Edit: it’s actually $post_count and $current_post that will be useful to you.
Related Posts:
- Endless loop with wp_insert_post and wp_update_post
- Add Incrementing ID to each paragraph in the_content
- post__in – Placing content from a foreach loop inside of an array
- In a foreach loop, how do I target the last item in the loop?
- How to iterate through database until it find a match
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- How to print out menu names in the foreach loop?
- Output meta into arrays
- Need to add class to first element in a foreach loop
- Foreach displays from last to first
- Simple foreach loop help needed in wordpress “the loop”
- How to print redux gallery feilds id? [closed]
- How to check all items in a loop have post thumbnail?
- Get featured image outside the loop using foreach
- Why loop renders only last metabox from array? [closed]
- Foundation modal in wordpress php loop
- ACF field not appearing correctly in loop
- Eliminate duplicates in a foreach loop [closed]
- Wrap every 2 divs in row – for each loop [closed]
- ACF loops false value with repeater and checkbox
- How to place comments_template(); outside the loop?
- How do I prevent one of two multiple loops from repeating on a second page?
- Hook into the loop via a plugin, and output something after every X post?
- Two custom loops, pagination, offset
- Access to Media Library
- Store loop into array
- Looping through WP_Post Object
- How do you split multiple-column loop on category archive page?
- How to Loop within a Loop (Display Children and then Grandchildren)
- Run The Loop over array of post objects
- Enable infinite scroll on single.php [closed]
- Show Custom Taxonomy Title
- How to loop through ALL pages?
- Does get_template_part pull data once in a loop?
- How to exclude specific category from the get_the_category(); array
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Get titles of all posts with current tags except current post
- How to retrieve “sticky” post outside the “loop”?
- Show a different post every 3 days [duplicate]
- How to Display a Single Post Excerpt
- Using get_the_excerpt() Before The Loop
- How to make sure content doesn’t display if selection is empty
- code suddenly appearing from my tempate second loop
- wp_query inside the_loop
- How to go about combining dropdowns / filter queries?
- woocommerce get_price_html not pulling in correct price
- How to fix pagination for custom loops?
- WordPress Rewriting the DOM?
- How to display posts by vote count and if no value continue with latest posts with no votes?
- Sort results by groups of numbers and letters
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- Display post list with different styles
- Loop for sticky posts
- WP Loop. If featured image is a panorama (3:1 ratio) execute some code
- How to avoid duplicates when creating recent network posts
- Trying to get property of non-object in shortocde
- variable value disappears in a second loop
- How to Loop with the final result formatted differently?
- Tags on page (not post) returns nothing – why? Improved clarified question!
- Include future posts in tags and in search
- Display child page content of a specific parent on home page
- How to wrap every 3 posts in a div (and close the last div too) [closed]
- Dividing the loop to style post differently
- Show terms in archive page
- Problem in replacing the_content with the_excerpt()
- Loops for cat links not looping for wordpress site
- Skip 5 latest post while paging?
- Sort posts according to a numeric value entered with ACF
- wp_get_attachment_url not fetching URL?
- get the value for ALT is we check to see if an actual ALT value is set, if not we use the caption and if no caption is set we use the title
- Display all categories including sub categories under a list ul
- How to get all multi-select user meta values and add them to an array?
- How to resolve a reload loop issue in the frontend when logged in to WordPress multi-site backend admin area
- Exclude Posts Using Meta Query and User Meta
- How fix error in the WordPress loop?
- Excerpt isn’t working or am I missing something?
- Can I temporarily disable global $post?
- Shortcode for pulling specific Post Title outside loop when ID is passed in
- Show a list of user posts in the user admin page
- Efficient way of querying for a “fallback” post?
- Infinite Loop after Genesis Theme Upgrade
- Create a hierarchical loop at predefined markup requirements
- enumerating custom taxonomies?
- Active class for my flexslider in WordPress
- WordPress loop only displays 5 articles max?
- How to display thumbnail if post is assigned one otherwise not
- get_template_part() to render single page Theme
- Can’t see custom field after the Loop [closed]
- Showing related posts (custom post type) outside of the loop
- Looping taxonomy in taxonomy?
- Paged homepage – requirements?
- Least Number of Loops to Create Custom Homepage?
- The Loop for my theme with static front page is not working
- WordPress loop: Display if posts exist
- How do I filter a custom post type loop by a field?
- Showing ads after posts in home page
- How to handle parent and child pages?
- Prevent duplicating specific column from database table
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop