The first post doesn’t get counted because you have this in your if statement:
0 !== $wp_query->current_post
According to The Codex on WP_Query:
(available during The Loop) Index of the post currently being
displayed.
Being an index of the array, arrays always start off at 0 as it’s first item. So by having that in your if statement, you are skipping the first post. To make this effective you would actually have to +1 to current post index THEN get the modulus, otherwise it will still skip the first post:
( $wp_query->current_post + 1 ) % 2
Hopefully that works!
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 Loop not Returning Permalink
- Two posts in same div – WP loop
- 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]
- 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?
- Can I add generic numbering HTML classes to items as a loop runs?
- something strange is happening to my code
- How can I access specific posts brought back by query_posts?
- Separate First Post Loop
- Query posts only with actual text content (not including shortcode or images)
- query_posts clarification needed
- Exclude current post ID from loop in sidepbar.php
- 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 display fields from the loop in two separate divs
- how to add 4 post in one carousel slide
- Automatically create a loop for post ID
- 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?
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- How to do query_posts on tags pages
- Limitless amount of posts in custom archive page
- Use Base-URL with Query-Loop
- Show scheduled posts in archive page
- post__in – Placing content from a foreach loop inside of an array
- loop query exclude meta_key with meta_value
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- add_filter() doesn’t work in loop
- The Loop in Static Page
- How can I use get_permalink() outside the loop?
- Content/Excerpt length control for a specific loop?
- Problem the_permalink
- Loop posts only excluding first post
- Loop repeating design pattern
- Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?
- Create static front-page with 3-5 recent posts
- Customize WooCommerce Product Images (Placement and size) [closed]
- Create a loop that gets pages with their template
- get latest 5 posts and a specific post and sort in a specific order
- How to check if a post exist?
- Why cant you place the Loop outside of the index.php?
- sticky post in custom loop
- On single.php, fetch 2 posts created after and 2 posts created before in relation to the actual post (using menu_order)
- Post classes in the loop are being changed in certain themes
- Wrong post title displayed from loop
- Exclude page name from loop
- PHP if post is already displayed, then
- How to style first post differently with ‘get_template_part’?
- in Foreach Loop the Description is not showing?
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- get_posts output always same post
- Second Loop Showing Only One Post on Single Post Page
- Pulling in featured image into default recent posts widget
- Calling function in loop causes repeat data
- Change position of entry title
- Override orderby to create list of users by custom meta_value
- Loop info in jquery Tabs – loop into a variable?
- Create a Loop with Posts Ordered by Most Recent Comments
- Insert content above an embedded video inside Wordress’ php the_content
- Loop two different category WP_Query
- How do I stop the same post showing multiple times in a archive?
- Use ACF Category Image for all Taxonomy Archive Views
- Loop with custom posts, to include information from different custom post type
- the loop printing post in one grid
- Transient not working for external data
- the_title() Returns the page title instead of the post
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How to fix pagination for custom loops?
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Loop from another WP site onto mine
- Having issue with WordPress loop
- I need to update the post query? [closed]
- Wrap every 2 divs in row – for each loop [closed]
- How to add class to the last image of the last post in a loop
- Multiple loop with pagination in same page
- Show number of posts AND number on current page (cannot make it work)
- wp_mail function not working in user query loop
- How to set and retrieve cookies while in the loop