Support

Account

Forum Replies Created

  • 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 );
    
  • I can mention as well that in my example above the only ‘place’ field satisfying both the ‘date_clause’ and the ‘heure_clause’ contains a:1:{i:0;s:5:"19479";}.

  • Ok for this query I won’t have more meta_key to add so i’ll leave my snippet (FYI it actually comes from the WP_Query Codex page – cf. subtitles “Mulitiple orderby/order pairs”).
    Glad to read yours though as I am not familiar with multi-meta_key queries.

    Thank you for your kind support.

  • Oh thank you John, I just notice your answer after replying to my own thread.
    It seems to be working with my snippet. Is it important to use the featured_clause as in your snippet ?

  • Phew, finally found out what was wrong…
    Query args should be as follows:

    $cdm_front_query_args = array( 
        'post_type' => array( 'post', 'events' ),
        'posts_per_page' => 9,
        'meta_key' => 'pin_home_page',
        'orderby' => array( 'meta_value_num' => 'DESC', 'date' => 'DESC' ),
    );
Viewing 5 posts - 1 through 5 (of 5 total)