Nested meta_query with multiple relation keys

Question

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:

0
, , , , Andrew Odri 2 months 0 Answers 37 views 0

Leave an answer