Order WP_Query by meta_key priority when 'OR' relation used for multiple meta values

I have a WP_Query that queries posts by an ACF date field AND an ACF true/false field. I am requesting all posts that have a date field value past the current date OR have the true/false field checked true be returned. It appears like such:

$args = array( 
    'post_type' = 'post', 
    'posts_per_page' = 6,
    'meta_key' = 'event_date',
    'orderby' = 'meta_value_num',
    'order' = 'ASC',
    'cat' = 3,
    'meta_query' = array(
        'relation' = 'OR',
        array(
            'key'     = 'event_date',
            'value'   = date('Ymd'),
            'compare' = '='
        ),
        array(
            'key'     = 'recurring_event',
            'value'   = 1,
            'compare' = '=='
        )
    )
);

This works great except for the order. It lists the True/False true posts first, most likely because the event_date field value is blank. I would like it to still order the posts by event_date and then place all the posts with the recurring_event value to true afterwards.

I am getting this as the results:

  1. Post 1 - Recurring Event Selected True
  2. Post 2 - Recurring Event Selected True
  3. Post 3 - June 1st, 2022
  4. Post 4 - July 1st, 2022
  5. Post 5 - August 1st, 2022

But I would prefer it like this:

  1. Post 1 - June 1st, 2022
  2. Post 2 - July 1st, 2022
  3. Post 3 - August 1st, 2022
  4. Post 4 - Recurring Event Selected True
  5. Post 5 - Recurring Event Selected True

Do I need to sort the array independently after queried or is there a way to accomplish this through the orderby field?

Topic advanced-custom-fields meta-query wp-query Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.