Support

Account

Home Forums General Issues Query ACF field with nested AND OR LIKE Reply To: Query ACF field with nested AND OR LIKE

  • Eventually! Bad nesting syntax of mine, not related to ACF, sorry.

    
    $args = array (
      'posts_per_page'  => -1,
      'post_status' => 'publish',
      'post_type'         => array( 'my-cpt' ),
      'meta_query'  => array(
        'relation'     => 'AND',
        array( 
          'relation' => 'OR', 
           array(
                          'key'     => 'place',
                          'value'    =>  '"14979"',
                          'compare'   => 'LIKE',
                          ),
           array(
                          'key'     => 'place',
                          'value'    =>  '"8917"', 
                          'compare'   => 'LIKE',
                          ),
        ),    
        'date_clause' => array(
          'key'     => 'date',
          'value'    => date('YmD'),
          'compare'   => '>=',
        ),
        'heure_clause' => array(
          'key'     => 'time_start',
          'type'    => 'NUMERIC',
          'compare'   => 'EXISTS',
        ), 
    
      ),
      'orderby' => array(
        'date_clause' => 'ASC', 'heure_clause' => 'ASC'
      )
    );
    $cal_query = new WP_Query( $args );