Support

Account

Home Forums Front-end Issues query by date Reply To: query by date

  • Hi Elliot

    That’s the code i used:

    <?php $args = 
         			array(
         				'post_not_in'    => array($donotrepeat),
                                    'post_type'       => 'chuchi_event',
         				'meta_key'        => 'event_datum',
         				'orderby'        => 'meta_value',
         				'order'           => 'dsc',
                'meta_query'  => array(         
                      'key'     => 'event_datum',  
                      'value'   => date("Ymd"),  
                      'compare' => '<=',          
                      'type'    => 'DATE'         
                                      )     					           
         			      ); 
            
              echo '<pre>';
    	        print_r( $args );
              echo '</pre>';
              die;
         
            $events = new WP_Query($args);
         
            ?>

    That’s the output:

    Array
    (
        [post_not_in] => Array
            (
                [0] => 
            )
    
        [post_type] => chuchi_event
        [meta_key] => event_datum
        [orderby] => meta_value
        [order] => dsc
        [meta_query] => Array
            (
                [key] => event_datum
                [value] => 20131218
                [compare] => <=
                [type] => DATE
            )
    
    )

    I hope it’s what you are looking for.
    Thanks