Why not just use a counter and then conditional logic?
$i = 0;
while($loop->have_posts()) : $loop->the_post();
if($i === 0){
echo '<div class="a">'.other_stuff().'</div>';
} elseif($i === 1){
echo '<div class="b">'.other_stuff().'</div>';
} else {
echo '<div class="default">'.other_stuff().'</div>';
}
$i++;
endwhile;
Related Posts:
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]
- Multiple posts with one loop iteration
- post__in – Placing content from a foreach loop inside of an array
- Post Loop not Returning Permalink
- How to Loop within a Loop (Display Children and then Grandchildren)
- Exclude first 2 posts with meta_key from loop
- Better way to display posts from specific categories, in a grid layout
- popular post weekly and monthly
- 3 Posts in Loop, Show Stickies First
- Query last updated posts (posts updated in the last 24 hours)
- Displaying terms based on loop posts?
- Duplicated posts on category page
- Make blog page show 10 on first page, 9 on every other page
- How to display posts by vote count and if no value continue with latest posts with no votes?
- query_posts() vs get_posts() multiple loops [duplicate]
- Problem with displaying HTML content after in_array [closed]
- Exclude first post (sticky or not) from the loop using query_posts()
- How to order by multiple fields using standard query_posts?
- Pagination not working in category listing [duplicate]
- How can I improve the performance of this query_posts loop?
- Include current post into loop
- Array ids post to function have_post
- Can’t access PHP array inside script localization from javascript
- Output meta into arrays
- Trying to get property of non-object in shortocde
- Adding div after every two post on main loop! Why will first post not get counted?
- How to create a multidimensional array with multiple loops
- How to get user ID’s from multiple usernames?
- Separate First Post Loop
- Loop through an array inside a class using foreach [closed]
- Query posts only with actual text content (not including shortcode or images)
- query_posts clarification needed
- CPT while loop not working
- display post tags on single.php inside loop
- Exclude posts based on an array
- Exclude current post ID from loop in sidepbar.php
- Add 2 values to post__not_in
- Why does my WP_Query pagination on a custom page.php only loads the homepage?
- Get a Post Loop based on Logged in User information into a Shortcode
- how to add 4 post in one carousel slide
- Query posts and display all dates in repeater field in chronological order
- Can’t print out returned value
- Query counting excluded category on paged loop
- get_posts and wp_autop (remove filter)
- query_posts ignores the argument
- The Loop isn’t working
- Twitter bootstrap carousel multiple items in carousel
- show posts from one category with comments only
- Least Number of Loops to Create Custom Homepage?
- WordPress loop: Display if posts exist
- How can I access ‘key’ and ‘value’ from an array in a for loop?
- How to do query_posts on tags pages
- Limitless amount of posts in custom archive page
- How to get files from loop for zip
- Using the Loop to show all levels of subpages under a parent page? Halfway there
- Cleanest Way to Select Every Second Element in a Loop?
- Display subpages under parent page as a list within a loop
- When to use wp_reset_postdata();
- Why do themes have `while( have_posts() )` in templates like single.php?
- Related Posts loop – offset
- Too many nested wp_query loops in this hypothetical query?
- Showing current subcategory
- WordPress Loop – Style rows of posts differently
- Generating dynamic Tabs with multiple query post loop
- How do I override part of the main loop in my child theme?
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- Only display videos and images in the_content() within loop
- Publish Categories for a particular Author on a given Post
- Getting a custom field in the middle of a loop
- Pagination on Single Post
- Display Posts Only with Specific Tag
- How to get my loop to paginate?
- Get author Meta for particular user inside the loop
- Foreach displays from last to first
- value of metadata is null wrong use of if statement
- Count post views in loop
- When to use WordPress loop or Foreach loop?
- issue with if/elseif in_array inside foreach loop display only one post
- How do i find and restore a sidebar that i accidentally deleted? [closed]
- Posts not showing
- using update_user_meta to rank users
- Can’t grab author info outside of the loop
- How to tell if all posts are only in one category?
- Custom archive page for custom taxonomy and pagination issue
- WordPress posts in the loop not stacking side by side
- Create an archive page(loop) for edd products (music files) with an audio player?
- the_content() keeps repeating itself
- Show different Google Map markers for different post_meta values
- Foundation modal in wordpress php loop
- My loop of random posts drags in comments of said random post
- Why my title change the last post title in my loop?
- How to fix pagination for custom loops?
- Get gallery and product gallery images full size
- Loop not showing up on page template
- How to end this loop properly?
- Custom Post Type archive above Single Post in single.php (same author)
- Duplicate post problem
- How i can display all posts order by years