There’s no need to split the array, you can just close the first div once you’ve counted up to four elements of the array.
$args = array(
'post_type' => 'event',
'meta_key' => 'date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'posts_per_page' => 8,
'meta_query' => array(
'key' => 'date',
'value' => date('Y-m-d',strtotime("today")),
'compare' => '>=',
'type' => 'DATE'
),
);
$events = new WP_Query( $args );
$count = 1;
if ( $events->have_posts() ) : ?>
<div class="column-1">
<?php while ( $events->have_posts() ) : $events->the_post();
// YOUR CONTENT
if ( $count == 4 ) { ?>
</div>
<div class="column-2">
<?php }
$count++;
endwhile;
wp_reset_postdata();
endif;
?>
</div>
Related Posts:
- Can an array be used as a meta_query value?
- How do I dynamically generate args for wp_query?
- How to use $query->set with post__in?
- Exclude posts based on meta value
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- extract serialized array to use for wp-query
- array_rand not working correctly?
- Order a WP_Query by meta value where the value is an array
- Using multiple variables to assign categories to an array
- Sending simple variable on single page to WP JSON
- in_array not working on dev server but works on localhost
- Combine multiple queries, array_unique returns nothing
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- How do I use WP_query with multiple post IDs?
- Inject post (from specific category) between posts in Loop
- is_page() not working from within a plugin
- Metabox repeating fields – radio buttons not saving correctly
- How can merge two arrays values in one array and save in database
- Passing JSON data from WP Query into AJAX causing NULL errors
- AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely
- Result of Custom WP_Query appears on 404 Page (but result are found!)
- Show only one post for each author ( Page loads too slow )
- Compare two meta key values against each other inside the get_posts array?
- How to add 2 posts under another post? Formatting should be intact
- WP_User_Query order by meta_key that is an array
- Count number of published posts by type
- How to display custom field on homepage
- Can’t increase posts_per_page by variable
- List of posts by day of the week
- WordPress WP_Query() Not working properly
- Get taxonomy terms only of the WP_Query current posts
- Get category name from custom loop and echo it once
- Hide post if matches current month and year
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- Create shortcodes within foreach loop (using array)
- Random order of WP_Query results with highest meta value
- get current custom post ID by WP_Query method
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Create WP_Query to search for posts by their categories or their parent/child categories
- If Query In Sidebar
- Reprinting tags with all attributes
- Checking array against author id in loop
- Security for data obtained from the database
- How to get all author posts outside of author templates
- Grouping posts by a custom meta value
- How to get post ID in a Page?
- How to retrieve the data from the sever and displaying it in a page?
- Error while setting role
- How to override url params with rewrite rules vars?
- How to display SQL query that ran in WC_Order_Query?
- Loop over Array and get the distinct ids
- Store metakey value as an array
- Remove empty terms from array, sort alphabetically, update back to repeating field
- Only show first image in foreach loop
- Post not populating for custom post type based on category selection
- Filter by field with array value in ACF on WP REST API
- Infinite Loop – WP_Query
- Multidimensional Array
- echo var into wp_query
- Only load certain artists on this page
- How to make sure relative URL works when site is not on root domain?
- Toolbar Hidden in a Virtual Page
- Finding and removing duplicates within WP Arrays
- Wp Query : Order by distance lat,lon
- get different meta-data of a complicated query at the same time
- Using a new WP_Query inside the loop
- wp_query – Exclude the first thumbnail from lazy loading on archives
- WordPress sorting posts by date and title using a dropdown
- How to get specific multiple pages excerpts at homepage?
- Usermeta data unserialize, extract and display in table in WordPress
- ACF – Get ID of relationship field in flexible content
- Replace an array (with identical values) with another array in the_content
- Wp-query output correct, but the loop shows one less item (only sometimes)
- How to display sticky post always at the top (before regular post) in wordpress?
- wordpress query returning unexpected results
- Custom Post type Ajax search results
- Display only upcoming events / Show all events when archive year is selected
- direct query to post_meta table
- Add post class in custom loop (WP_QUERY)
- Add custom filter to register data in array
- Page returning ID from array, how to return the correct values for post in acf wordpress
- Display a post based on its metabox selection
- Unserializeing multiple column values that are stored in one database results variable
- List sibling pages widget, exclude current page
- Why does WP_Query show only the same post even with different categories and endwhile?
- wp_get_archive for category returning different URLs on different but similar sites
- show/hide attachments
- get_permalink returning first letter
- WP_Query based on another query on the page
- How to print array of specific item
- Does wp_query and query_posts affect website performance? [duplicate]
- WordPress post pagination on custom template not working
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- Show post like this image in my newssite [closed]
- save array of objects with update_option
- How do I run the following script from my articles page?
- Three different queries on same page
- How to sort search result by post_title, then by post_content
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress