meta query and code example
Example 1: wordpress meta_query relation
$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'
)
)
) );
Example 2: meta_value wordpress
$meta_query_args = array(
'relation' => 'OR',
array(
'key' => '_my_custom_key',
'value' => 'Value I am looking for',
'compare' => '='
)
);
$meta_query = new WP_Meta_Query( $meta_query_args );