• Hello Support,
    is there any ways to use meta_relation=”OR:AND” ?

    in my case there are two fields are in OR condition and one field with AND how I can create that using this

    Below is my post query

    $event_post_data= array(
            'post_type' => 'post',
            'posts_per_page' => -1,
            'post_status' => 'publish',
            'meta_query' => array(
              'relation' => 'AND',
              array(
                'relation' => 'OR',
                array(
                  'key' => 'starts_at',
                  'value' => date('Y-m-d'),
                  'compare' => '>=',
                  'type' => 'DATE'
                ),
                array(
                  'key' => 'ends_at',
                  'value' => date('Y-m-d'),
                  'compare' => '>=',
                  'type' => 'DATE'
                ),
              ),
              array(
                'key' => 'branch_id',
                'value' => $branchId,
                'compare' => 'LIKE',
                'type' => 'value'
              ),
            ),
            'meta_key' => 'starts_at',
            'orderby' => 'meta_value',
            'order' => 'DESC'
          );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Multiple meta_relation’ is closed to new replies.