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
- Get excerpt using get_the_excerpt outside a loop
- Some doubts about how the main query and the custom query works in this custom theme?
- WordPress Alphabetical Glossary close div in loop
- Listing all posts from current category on page
- How to make multiple Column in archive Page?
- Filtering posts by multiple taxonomies
- Help with Changing loop.php?
- How to insert content from another Custom Post type into Post?
- Change front-page layout after x amount of posts ( while in the same loop)
- How can i use the same template file with a widget and category loop?
- angularjs not displaying all posts
- Checking array against author id in loop
- How do I make a variable available inside partials?
- is_active-sidebar loop
- Unable to change the “Read more” text inside the_excerpt
- How to get post ID in a Page?
- Conditional: IF current user has NOT commented on current post (not including post author)
- Change post order by meta key, per post basis
- Loop Problem: Displays same set of post for all categories
- Hiding a row in the loop if empty
- Pagination on custom post type on front-page.php
- get_template_part() Not Working in Loop
- Querying another post category to match current post and display in loop
- get_delete_post_link() inside Loop stubbornly returns nothing
- Comments_template doesn’t work
- Get markup for post without loading into the template
- Display specific posts on home page
- Displaying member join date on page
- Ascending order has strange effects on wordpress loop
- get post images to link to external sources
- Set depth of pages to fetch
- Ordering of posts, 2020 Year showing as next event when should be last
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- How to execute a user loop with shortcode
- Loop Posts Outside of WordPress Installation
- How to include posts from one category, into a separate category of posts?
- how do i make this loop work
- show latest authors blog post
- display only parent replies count in index.php
- using the loop on a page
- While loop inside another while loop
- Fix html inside a for loop [closed]
- Insert multiple custom components after x-number of posts
- Use Base-URL with Query-Loop