I'm trying to create an events page that lists events (custom post type) within the week. I'm having trouble properly selecting only the posts that have a 'start_date' that falls in the current week.
Here is my code:
$day = date('w'); $week_start = date('d-m-Y', strtotime('-'. $day . ' days')); $week_end = date('d-m-Y', strtotime('+' . (6 - $day) . ' days')); $args = array( 'post_type' => 'hcc_events', 'order' => 'ASC', 'meta_key' => 'start_date', 'orderby' => 'meta_value', 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'start_date', 'value' => $week_start, 'compare' => '>=', 'type' => 'DATE' ), array( 'key' => 'start_date', 'value' => $week_end, 'compare' => '<=', 'type' => 'DATE' ) ) );
Right now nothing is output at all. Any help is appreciated!