I want to query by 1 meta key, but sort by another key that may or may not exist, and then by post date
So the end result would be something like:
Meta Key A / Date 1
Meta Key A / Date 2
Meta Key B / Date 1
No Meta Key / Date 1
No Meta Key / Date 2
Query args like the following are not returning any posts:
$customer_orders = get_posts( array(
'numberposts' => $order_count,
'meta_query' => array(
array(
'key' => '_customer_user',
'value' => get_current_user_id(),
'compare' => '=',
),
array(
'key' => '_dealer_number',
'compare' => 'EXISTS',
),
array(
'key' => '_dealer_number',
'compare' => 'NOT EXISTS',
),
'relation' => 'AND'
),
'orderby' => 'meta_value date',
'order' => 'ASC'
) );
Is this possible with WP_Query
args or do I need to filter posts_orderby
? If so, what might I use?