The problem is that you are displaying three images each time $i is increased by one.
In the first run through the for loop, $i = 1, you check if $i is 2, and then you display the image for $i (1), $i+1 (2), and $i + 2 (3).
On the second run through the for loop, $i is 2, you check if $i is 2, and then you display the image for $i (2), $i+1 (3), and $i + 2 (4).
Solution: change your loop to increment by 3:
for($i = 1; $i< count($posts); ($i=$i+3)) {
Or, you could change the content of your loop so that you display only one image each time you go through, and check $i to see whether it should be a large image or small.
Related Posts:
- How to show the posts list into a static page? Problems to use the loop into a static page
- Should we trust the post globals?
- Get first post from wp_query
- WP_Query: Why is sticky post not first item in loop?
- Query *only* sticky posts
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- How to know if get_posts() failed?
- Reverse chronology of post listing
- WordPress Number of Posts Not Changing With posts_per_page
- how to display full post with pagination on home page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Specific loop in Shortcode
- Search widget breaks when using multiple loops?
- Converting multiple loops into one single loop with pagination
- Display posts with comments closed, with pagination?
- Group posts by year in loop
- How would I get 1 latest post from a query for 5 posts?
- Loop through all product posts?
- Why won’t my taxonomy query show up?
- WP Query – duplicated posts once including tags in search results
- Display post from current category and same tag?
- page.php showing loop of posts and not page content
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Exclude category from
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- WP Query – Posts Per Page not working in combination with category__in
- Pausing and Resuming WP_Query results
- How to : pagination in 3 different custom loops on the same page
- List authors with the last post title and order by last post date
- wp_query random post
- Possible to alternate between two loops
- How to get posts published on the latest date?
- WP_Query with custom post type ID
- Page and post loop same template
- Getting blog pagination to work on page set as front page
- Display current post position in Elementor Posts widget
- WP_Query: Show 10 posts in date order, first three random
- WordPress Loop: How to display recent posts in multiple divs
- How to display post list in a table layout (multiple queries in single loop)
- Not all posts showing in query
- Custom WP_Query not working correctly
- WP_Query of Category Not Showing First Post
- Cant’ Grab WordPress Built-in Posts Through Loop
- Display 3 posts with different HTML markup using a loop
- I can’t find the relevant part of the loop in my theme file. How do I find the full content with “More…”
- While loop in functions.php outputting the_title() of each post on frontpage
- Display specific posts based on an ID of another post
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- Moved a website and excerpts don’t work for old posts
- show loop id post , only first id can read
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Double loop output
- Loop through all posts showing duplicates
- Wp_query loop is not working as it should
- Display post order ranking within wordpress loop
- Displaying a specific sub-category’s posts from wp_query
- WordPress loop uses unmodified posts array, why?
- Post are not showing up
- Advanced Post Display/Pagination/Ordering
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Adding a category at even positions on main loop with modified pagination
- Make assigning post to a specific category equivalent to assigning it to all categories
- wordpress taxonomy results
- The post order is different for logged-in and non-logged-in users? [closed]
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- How do I show the post title if an advanced custom field hasn’t been used?
- First post in loop displays twice
- Wp_query WooCommerce products
- posts_per_page – Repeats only first posts ‘post__in’ array
- Get posts after calculating meta key
- WordPress Ajax load doesn’t work
- Random sort within an already sorted query
- Search by Hyphen
- rewind_posts() – what actually the use of it, and where using is required or preferred?
- Find most recent authors
- Exclude posts with specific meta_value while sorting by a separate meta_value
- Fetch posts from current week (Sunday to Saturday)
- Exclude posts with empty post_content in wp_query
- Exclude posts from featuring
- AJAX filter posts by year
- Admin Notices don’t display on the admin screen for certain post
- I am unable to publish/update post
- is there a way to show the the post title after the image?
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- get_the_excerpt() is not working as expected – returns wrong text
- Select only post id and meta value with WP_Query
- Get the amount of posts on a current page
- How to display posts on custom page without declaring a posts page in reading settings?
- How to check if there are posts with the same tag
- How do I allow certain users to make a certain type of post?
- WordPress Query – Display 5 posts (same post type), each from a given tag
- Show posts from two specific category in WP_Query
- Permalink Short code showing unnecessary link text inside the loop
- How to pull latest posts from a specific category
- a WordPress connected to 2 database
- post->ID displays the same ID number for every post
- List posts related to category on a div [closed]
- query_posts different amount of posts per page [duplicate]