Support

Account

Home Forums General Issues Querying by Post Object value Reply To: Querying by Post Object value

  • John, this is great, thank you (as always). It worked exactly as you suggested.

    I am now trying, however, to make sure I can still present them in date order (the other meta query). I’ve been using this to do that in other feeds:

    'orderby' => 'meta_value_num',
    'order' => 'ASC',
    'nopaging' => true

    Of course, now there are two meta queries, there are two meta values too, so how can I specify which is to be used for ordering? At the moment it seems a bit confused.

    Here’s the whole thing as it stands currently:

    $byartist_args = (array(
     'numberposts' => -1,
     'post_type' => 'Event',
     'meta_query' => array(
      'relation' => 'AND',
      array(
       'key' => 'artist',
       'value' => get_the_ID(),
       'compare' => '=',
      ),
      array(
       'key' => 'event_date',
       'compare' => 'BETWEEN',
       'type' => 'DATE',
       'value' => array($date_1, $date_2),
      ),
     ),
     'orderby' => 'meta_value_num',
     'order' => 'ASC',
     'nopaging' => true
    ));

    Thank you!