You need to start Row class after every 2N+1 post.
And end the Row class after every 2N+2 Post.
Try this one
<?php $counter++;
if ($counter % 2 == 1) : ?>
<?php echo '<div class="post-wrapper">'; ?>
<?php endif; ?>
<?php get_template_part( 'templates/blog/blog-2-cols', get_post_format() );?>
<?php $counter++;
if ($counter % 2 == 0) : ?>
<?php echo '</div">'; ?>
<?php endif; ?>
Related Posts:
- Print Current Post Index number within Loop
- Should we trust the post globals?
- rewind_posts() – what actually the use of it, and where using is required or preferred?
- How to show list of posts by author and category?
- Override the default number of posts to show for a single loop?
- WordPress Number of Posts Not Changing With posts_per_page
- Count singular post views automatically
- Looping through posts per category gives same posts for each category
- Find most recent authors
- Get the author of the latest revision
- How to have different content in the loop and single
- Strange switch_to_blog() issue
- Multiple loops in same page, without duplicate content
- loop not displaying posts on custom template page
- How to Display Post View Count
- Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?
- The correct way to call posts with ajax
- custom wordpress post loop – hide iframe content
- Divide Loop Into Days & Categories
- Converting multiple loops into one single loop with pagination
- How would I get 1 latest post from a query for 5 posts?
- Alternating post layout
- Check to see if specific loop has less than certain amount of posts
- How to display different number of posts
- Alternate row and columns every X posts
- Adding specific post category between posts in loop
- How do I restart my loop with get_next_post()?
- Multiple loops are not reset
- Exclude category from
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Pausing and Resuming WP_Query results
- Post Loop Missing Most Recent Post
- How to : pagination in 3 different custom loops on the same page
- Sharing post from archive page (loop) doesn’t work
- Start WP Pagination From Number 1 in URL
- Use two different post_per_page limits with infinite scroll
- Wrong post title displayed from loop
- Multiple Loops Breaking Pages
- Change all author links in Blog roll
- Showing categories and subcategories with posts
- Get the amount of posts on a current page
- older blog posts not showing in new theme
- How to get posts published on the latest date?
- How to only publish posts with image in it
- Page and post loop same template
- WordPress Query Posts From Category Post on Static Page
- Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
- WP_Query: Show 10 posts in date order, first three random
- How include css class based on post ( in loop ) slug?
- WordPress Loop: How to display recent posts in multiple divs
- How to display posts on custom page without declaring a posts page in reading settings?
- Cannot implement byline into posts container in single.php
- Optimizing the blog loop
- How to check if there are posts with the same tag
- Accessing Post ID Within Loop
- Custom WP_Query not working correctly
- Different number of posts per row in grid layout
- WP_Query of Category Not Showing First Post
- How come this loop is not working? [closed]
- posts going to 2 pages/categories only show up in 1
- Using the loop to set locations for all posts on a single google map
- Separate top level categories on archive-product.php by meta
- While loop in functions.php outputting the_title() of each post on frontpage
- Shortcode for Comments and Comment Boxes in Post Loop
- Permalink Short code showing unnecessary link text inside the loop
- Display specific posts based on an ID of another post
- How to distinguish pages created by woocommerce?
- Moved a website and excerpts don’t work for old posts
- Double loop output
- how to call recent post content in a loop ( only the content before read more tag)
- post->ID displays the same ID number for every post
- Posts are not showing up on next page.
- Can the_post_navigation() be outside of the loop?
- How to get all posts in gallery post format template
- Show Posts By Custom Field
- Querying multiple categories in the WP loop if one of the category IDs is dynamically obtained
- Post are not showing up
- How to make post button to a random post
- Post gallery as carousel
- Showing content from WordPress ruins page CSS using WP_Query, without, content does not show
- Add something after all sticky posts in The Loop
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Keep post format class with isotope filter
- Display Post by menu order
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to inject a post within a loop
- Getting rid of the blog page entirely
- Sort by category and then date?
- adding custom meta as well as looping through posts
- Loop not allowing infinite scroll after post per page limit
- Customise the appearance of 4 specific post ID’s within the loop?
- what template-part to call, to have my post in the center of the page?
- How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?
- ‘posts_per_page’ => ’10’ does not show any post
- How do I create a template page to show 3 blog posts?
- posts_per_page – Repeats only first posts ‘post__in’ array
- blog post displaying within older post – loop issue?
- View post with specific category id and name which I selected in the backend (drop-down option)
- WordPress Ajax load doesn’t work