This is really just a matter of logic. You need to conditionally print the div
markup. The counter in $wp_query
will let you chose every second post.
if (have_posts()) {
echo '<div class="posts-wrapped">';
while (have_posts()) {
the_post();
if (0 !== $wp_query->current_post
&& 0 === $wp_query->current_post%2
) {
echo $wp_query->current_post.'</div><div class="posts-wrapped">';
}
the_title(); echo '<br />';
}
echo '</div>';
}
Related Posts:
- Automatically create a loop for post ID
- Build a content and excerpt grid loop with paging and options for # of posts
- ACF page while loop breaks footer while loop
- Using loop pagination on single.php
- Syntax error when I try to insert my loop into an unordered list? [closed]
- How to get post ID in a Page?
- How to add post meta in while loop?
- Calling function in loop causes repeat data
- Posts are not looping through correctly
- How to break up php code to avoid echo
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- Is there anyway I can call the year once?
- How can I get my pagination loop to display the correct number of total pages?
- how to remove replicating a tag inside loop?
- How to only fetch certain Tag ID’s
- Div Missing In Custom Loop Query
- Create a hierarchical loop at predefined markup requirements
- What is the best way to get the first few post from WordPress in different divs using a loop?
- Pagination in category.php not functioning
- Implement “No related posts for this entry” into the loop?
- Saving meta box data from selected option’s value in database is not working
- How do I exclude the current post from the upcoming post query
- How to show correct td of table tags in wp_query loop
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Changing layout with wp_customise
- Converting HTML Template to WordPress Theme
- Multiple options not staying selected after saving
- Dynamic Stylesheet loads but doesn’t finish
- Filter Select results based on selection
- Using the echo command adds unwanted br tags to source
- Why WP_Query(‘showposts=5’) shows only 1 post?
- custom fields wordpress
- Logged in user ID as post ID
- Loop with slider (slider not loading)
- Sort query_posts for Parent Pages to menue order or the count?
- How to hide all child pages with post_query?
- Why the JavaScript code is ignored from wp editor?
- How to sort posts based on the value (number) of a post’s metadata?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Populate dropdown with Child Pages based on Parent Page chosen
- How to store data from multiple forms using ajax and php
- search and replace preword from author
- Embed html in php code
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- WP grandchild categories in nested ul li
- Use DOMDocument with ob_start breaks my HTML code
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Iterate through posts based on array of categories
- How to change redirection route to a php page for making it only accessible by logged-in members?
- get author_name from queried post
- Displaying Woocommerce Product Category in WordPress
- How can I add extra word in permalink when someone click download button?
- Increase offset while looping
- selected option if current category is the value
- Blog posts repeat
- How to add condition in wordpress loop? [closed]
- Woocommerce : Can’t get product info in loop
- How to set variable, pass it to a partial file and remove it after?
- how to refresh div on template part?
- How to remove ?wp-mce-4103-20162941
- Customize position of social icons in upme plugin [closed]
- Why Won’t My Inputs in a form with a Get method work together?
- parts of url disappear when using # inside href=”” [closed]
- Settings API callback function inserts html quotes from nowhere
- Input data from email form not going to JSON file
- How to get the value of input hidden html from text editor to custom page template?
- Alert Bar section within WP loop is displaying even though there are no posts
- remove post that has no content
- Different post styles depending on category
- How create a Shortcode with hover and complex options
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- Display category name only once inside loop
- Dot is not added at the end of href
- WordPress Multiple Navigation bars
- Position banner to right of logo in header – messed up my header file
- Commenting out unwated CSS/scripts in HTML with PHP
- Can’t find infinite loop cause
- Checking array against author id in loop
- How do I Turn This Into An if statement?
- How to separate HTML and WordPress files
- Add .htm extention to a custom taxonomy
- Load wordpress content in other domain
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Checkbox doesn’t stay checked, conten
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- Sort by page information by Ascending Numbers
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Make PHP work with HTML tags
- post thumbnail, conditions, else wont work
- Widgets in the loop if active
- Noscript not working as it should in wordpress site
- Show latest posts in a plain HTML website custom widget [closed]
- List posts that don’t have a specific tag?
- Changing the_posts_navigation() html output
- Can we count the WordPress Loop
- How to convert select to HTML with PHP tags inside of it [closed]
- Get post id within comments loop
- Is this spyware on my site or a real Java update?
- WP_Query fails despite having 1 post