Separate the posts in two different arrays, then loop over both separately:
$columns = array ( 'first' => array (), 'second' => array () );
$first_column = array( 1, 3, 4, 5, 6, 7 );
// separation
foreach ( $the_query->posts as $index => $post )
{
if ( in_array( $index + 1, $first_column ) )
$columns[ 'first' ][] = $post;
else
$columns[ 'second' ][] = $post;
}
unset ( $post );
// render one column
echo 'First column<br>';
foreach ( $columns[ 'first' ] as $p )
{
print $p->ID
. get_the_title( $p ) . '<br>'
. get_the_post_thumbnail( $p->ID ) . '<br>';
}
// render the next column
echo 'Second column<br>';
foreach ( $columns[ 'second' ] as $p )
{
print $p->ID
. get_the_title( $p ) . '<br>'
. get_the_post_thumbnail( $p->ID ) . '<br>';
}
Related Posts:
- How to exclude latest x posts from a paginated query?
- How to exclude latest x posts from a paginated query?
- Keep featured content post in homepage with original order
- How to get posts published between a date and today?
- How to Change Order of Posts in Admin?
- Query posts distinct authors
- How to get previous 10 days post from a specific date – WP Query
- Number of posts per page setting is not working?
- Exclude category on blog list page
- Can’t show comments count per post outside loop
- Only display posts with comments
- Order post by year DESC and month ASC
- Function to show random posts from a category
- Filter Posts By Tag
- Can I set and show “important” post in my blog?
- Improving WP_Query for performance when random posts are ordered
- previewing my posts on static page?
- Exclude newest post from category X but show rest
- Reset Popular post query?
- pre_get_posts query between 2 dates (date stored in custom post meta)
- how to get posts ids inside pre_get_posts filter?
- How To Get Posts With A Specific Word
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Display posts with tag that matches current post title
- Why is querying posts messing up my pages?
- Display all posts that were published before full post on single.php
- Category Foreach keeps looping?
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Blog page pagination is not working after using the offset argument
- Posts will not display on page-mypage.php
- Multi row post list
- posts_per_page option limits the number of Gallery items
- wp_posts table: safely remove unused columns to save database storage
- Display Posts on Custom Page
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Counter is skipping post when I still want it visible [closed]
- post__in not working with pre_get_posts, but post__not_in does work
- Query for first 3 posts to change the look and feel
- Archive template combined with post slider and regular posts
- How to only publish posts with image in it
- Shortcode with ‘year’ parameter
- On what hook can I get the queried object’s final state?
- wp_query with ajax
- How to give classname to post if post has no content?
- Get the most recently modified post date of most recently modified post
- Custom posts listing widget always returns 1 extra result
- WordPress post filter menu
- Custom Post Limit for homepage only without plugin?
- Bootsrap carousel for post
- Get postlist for each category using query_posts?
- How to save posts position on homepage after random function?
- WordPress query portfolio posts
- WordPress displays post on subcategory only
- How to get posts ordered by using their categories?
- Display 3 posts with different HTML markup using a loop
- Getting posts from some categories plus some individual posts
- How to assign a post to a post parrent?
- query for filtering published posts?
- get parent fields title, content excerpt etc
- AWS usage queries
- Pull in posts using post meta for REST API
- Move position in post list for a custom checkbox column
- How do I display main query posts in random order using add_filter
- How to merge the content of posts that have the same title?
- How to fetch courses in all languages in WordPress?
- How to show post views shortcode data for each post on Posts List Page?
- How can I use query_posts to loop through posts and construct my own content?
- Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday
- Show 5 posts and than 3 posts offset with pagination
- WP_Query to get posts in a specific tag or has post_format
- Make recent post display recent updated, instead of recent published
- Manipulate query to show specific post
- Querying posts from current category, using a variable as array argument
- Need help writing loop to display posts by categories in separate divs
- Sort / Filter Queries
- get_page_by_title() not working if special characters are present
- Modify WordPress loop after it has been run
- Query post category & remove any post id
- show latest authors blog post
- get “read more” with custom DB query like you would with WP Query
- How to get only current images of a post
- Ordering posts alphabetically by meta keys and title
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- How do I control the fallback query after the original query returned cero posts?
- Remove duplicated posts in the loop if post has more than one category
- Adding a category at even positions on main loop with modified pagination
- How to limit the number of results for all query_posts on mysite
- wp_query select if have comments
- How to limit post query to only return a total count of items with certain post statuses?
- Not displaying any articles on a custom made file
- wp trim function not working
- Change from all posts to specific categories post on main page?
- How to var dump urls for all posts
- Count words for all posts by all authors
- Word count for all posts of all authors
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- Dynamic archive of posts by date