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
- start_lvl Ignored in Custom walker_nav_menu
- What exactly does “Posts page” do in WordPress?
- Adding a search form inside a div
- Load custom field value into div with AJAX
- Display only text to WordPress loop without loosing the text formatting
- Blank on static home page?
- How to use a frontend URL with a Plugin
- How to change post count in wordpress loop?
- How can I loop into two different DIVS without repeating the DIVs
- WordPress loop specific thumbnail size
- Minify HTML, CSS, JS with PHPWee?
- Show Custom Taxonomy Title
- How can i display post loop in table format?
- Placing raw HTML inside a WordPress shortcode
- How to select WooCommerce products by post_meta and order them
- An unwanted inline style is added to my body tag
- Working with query_posts ( arrays and query strings)
- HTML tags in bloginfo description
- Transferring working local PHP site to wordpress – with database (MySQL)
- Cannot display or echo alt text on featured image
- Using Advanced Custom Fields to create a per page slider
- WordPress Search Results for Multiple Post Types
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Using the echo command adds unwanted br tags to source
- how to refresh div on template part?
- Input data from email form not going to JSON file
- Display category name only once inside loop
- Commenting out unwated CSS/scripts in HTML with PHP
- Hide HTML element (by class or ID) with PHP
- wp_query get the 2nd post
- Path for php file for inserting data through html form
- Widget back end radio button issue
- How to add div blocks after certain set of post
- Add shortcode in my div
- How do I remove a category from a wordpress loop>
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Illegal string offset error in wordpress theme options textarea
- posts_nav_link pulling in multiple post types
- Echo array value
- Is it possible to isolate and use WordPress functions outside of wordpress
- Hot to check if new posts have been published since page load and notify online users?
- Search bar for wp menu
- Products listing check if meta checkbox is checked
- Executing php on button press
- WP Website is shown in HTML
- Mysterious letters appearing at the top of a few pages
- Current WordPress Page Title as Search Parameter into A Tag
- If user has clicked link add class and store using PHP/WordPress
- How to Protect a private folder inside uploads folder, if User is not Logged In?
- Show the subcategory name based on current product
- How to center all text body in single.php at once?
- sessionStorage saves input value in browser but it is not loaded in the form field
- Changable favicon
- How do if all posts has this category ID then do this
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- AMP version of e-commerce without plugin
- View tag description on page
- Use PHP to inject HTML into before page renders?
- How to make a parent page for author.php?
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Multisite – Display different header content based on which site is accessed
- html to posts, jpg to featured image, zip file contains jpg and html
- Insert div after every three posts in home.php [duplicate]
- How do you change the tag font size in the repeater-template.php [closed]
- PHP tag in post content makes wordpress go crazy
- Display product attributes for current product
- Where to find the html for WordPress site? [closed]
- RegExp to EXCLUDE strip HTML (FOR SOMME) comments
- Pagination for div’s
- Create Customization Controls from Array
- How Can I Center the Logo in the Navigation Menu? [closed]
- How to have post count after each listed category
- How can I put a custom field as the link of a button shortcode?
- Transient Loop Not working as expected
- Conditional in foreach loop is outputting content twice
- is there away to hide php code in wordpress not to show in PAGES
- HTML in PHP problem [closed]
- How do I display WooCommerce products in my query to rows of 3?