I am curious whether WordPress is able to run nested meta_query
, with each having different relation keys? As of WordPress 3.0, tax_query
is able to perform this function; I’m wondering whether this has an equivalent with meta_query
.
$results = query_posts( array(
'post_type' => 'event_id',
'meta_query' => array(
'relation' => 'AND',
array(
'relation' => 'OR',
array(
'key' => 'primary_user_id',
'value' => $user_id
),
array(
'key' => 'secondary_user_id',
'value' => $user_id
)
),
array(
'key' => 'date',
'value' => array( $start_date, $end_date ),
'type' => 'DATETIME',
'compare' => 'BETWEEN'
)
)
) );
References:
- WP_Query Custom Field Parameters – Multiple Custom Field Handling
- query multiple taxonomy and show post count
- How navigation works in custom loop within shortcode?