Hello Everyone!
Having a hard time nailing down a WP_Query, hoping for some help. I have a custom post type for events, with a start_date and end_date field. I’d like to get a list of future or ongoing events. That is events with a start date or end date that is greater then now. Here is what I have, it give me back a list of events, but not in the correct order:
<?php
$query_args = array(
'paged' => 1,
'posts_per_page' => 6,
'orderby' => 'meta_value_num',
'order' => 'ASC',
'post_type' => 'event',
'post_status' => 'publish',
'meta_key' => 'start_date',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'start_date',
'value' => date('Ymd', strtotime('now')),
'type' => 'numeric',
'compare' => '>=',
),
array(
'key' => 'end_date',
'value' => date('Ymd', strtotime('now')),
'type' => 'numeric',
'compare' => '>=',
),
),
);
$my_query = new WP_Query($query_args);
?>