Order by the first array within a meta_query

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 }

Let current user know pending posts counts using wp_query

As others have already noted in the comments, using “posts_per_page” => 5, is better option than “posts_per_page” => -1, for your query as it will give you the information you need for your conditional check. Limiting what is queried is also something to consider – as honk31 mentioned. Along ‘fields’ => ‘ids’ you can also … Read more