You can use get_posts() for both event types and merge them.
$merged_events = array();
$upcoming = get_posts(array(
/* Your upcoming events args here. */
));
$past = get_posts(array(
/* Your past events args here. */
));
$merged_events = array_merge( $upcoming, $past);
foreach( $merged_events as $merged_event ) {
//Your loop
}
Related Posts:
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- Getting attachments by meta value
- querying with custom meta field with meta_query
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- WordPress altering my custom query, How to fix it?
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- Order by meta_key in custom post type doesn’t affect the query
- meta_key and meta_value not working together
- Order Posts by meta value AND published date
- How to make Meta Query case sensitive?
- Fetch Record based on meta key dates
- Meta_query with multiple keys and multiple values
- meta_query BETWEEN, but the range is stored in the custom field
- Extend product search with meta in WooCommerce
- how to make members list directory through wordpress post custom meta key.
- Large AND OR query timing out
- meta_value_num not ordering all items
- meta_compare not comparing whole integer
- Display posts with specific value first in query
- Get every post with value in meta key
- add_query_arg to compare and display events from a certain date
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- meta_query weird behaviour, static int will work, but not user data
- Query multiple post types, but different order for each
- Query ACF relationship field – Comparator IN – Value array
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- How do i create a custom post query when the meta value is an array?
- WP Query – grouping posts by same meta key, adding together values from another key
- meta_query is overriding default search
- Trouble with serialized metadata
- Comparing Meta Field date in WPQuery using Meta_Query?
- Getting posts by custom field value
- Query against multiple locations within single custom post type post
- WP_Query, ACF field and array
- Order by Date Custom Field
- Query by meta value (add a dropdown of all values)
- Order Posts By Custom Field That is an array of objects
- Custom WP_query and integrating into theme file
- Using custom field as ‘orderby’ value causing post grouping by publish date
- Compare meta key separation
- query post based on comparison
- Get posts by meta value except one post [closed]
- How to get products with the same custom attribute like ean code
- How to query posts based on lat-lng coordinate as post meta?
- Set Alias for meta_query arguments in get_posts()
- How can I use order_by to order by two meta_keys without excluding posts that don’t have those keys initialized?
- WP_Query orderby custom field then post_date in one query
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Using custom meta_query with relation not working as expected
- WP_Query meta_query where meta value ends in space
- Nested query inside Logical operator OR not working in meta_query
- What is an efficient way to query based on post_meta?
- How do I create my own nested meta_query using posts_where / posts_join?
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Exclude post on loop by multiple meta key value
- Custom Field sort not working (WP 3.8.1)
- Order posts by meta value and Date
- Query sticky posts with thumbnails
- Meta query with order by another custom field
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Single meta_query query using OR instead of AND in request’s WHERE statement
- How to do meta_query for attachments?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Why isn’t my `meta_query` array functioning properly?
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- Order by meta value (numeric value lower to higher)
- WP_Query with different postmeta filter for each categories
- Categorising search results based on Custom Fields
- Query based on custom fields start and end date
- Query posts with “non set” meta value
- Is it possible to retrieve all posts with a certain value for metadata?
- Ordering a mysql style datetime stamp with meta_query
- wp_query get data from advanced custom field in wordpress
- Wp_query with 2 meta keys and array of meta values
- Event with multiple dates, display events chronologically
- WP ForLoop to compare meta information of posts to determine what post to display
- Querying a large number of posts including their custom fields data
- Query posts by searching for a string in a meta field
- Custom meta_query order for Elementor based on post meta key [closed]
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- display ACF repater field in archive page
- ElasticPress is (aparently) messing with my search filters
- Meta query ignores multiple values of the key
- Check for not NULL not working in meta query
- Get unique post by meta value using wp_query
- WP Query. Ordering posts by another post types meta
- Complex Meta Query
- Get posts meta_query by repater field
- Query 3 meta_key and orderby
- wp_query sorting – one specific meta_key value at last and then sort by create date
- meta_query not working with the_content()
- Order Custom Field by Price
- Get closest event where meta_key field is an array
- Set right order for query that returns posts based on two custom fields
- Meta_query weird behaviour
- WordPress – Optimize the Meta Query for 3 meta keys at a time
- Sort wp_query of two post types using meta datefield for one and date for the other – possible?