Support

Account

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

  • I am still struggling with this. After more reading, experimenting, testing etc I have come up with this set of args for the query I am trying to create, but still with no output.

    <?php 
     //Set server timezone to GMT
     date_default_timezone_set('Europe/London'); 
     //Today's date
     $date_1 = date('Ymd', strtotime("now")); 
     //Future date - the arg will look between today's date and this future date to see if the post fall within the 2 dates
     $date_2 = date('Ymd', strtotime("+48 months"));
    ?>
    
    <?php
     $byartist_args = (array(
      'numberposts' => -1,
      'post_type' => 'Event',
      'meta_query' => array(
      'relation' => 'AND',
      array(
       'key' => 'artist',
       'value' => '"' . get_the_ID() . '"',
       'compare' => 'LIKE',
      ),
      array(
       'key' => 'event_date',
       'compare' => 'BETWEEN',
       'type' => 'DATE',
       'value' => array($date_1, $date_2),
       ),
      ),
     ));
    ?>	
    <?php $byartist_query = new WP_Query( $byartist_args ); ?>

    I can only assume that the issue is with this part, as everything else seems to be working okay:

    'value' => '"' . get_the_ID() . '"',

    There must be a way to compare the current post ID with the ID in a post object field and output based on this. Anyone?