I have a custom post type called 'events', I have a page which displays events by each month. Each event has a start_date and finish_date custom field (using advanced custom fields plugin) which stores the date as yymmdd. If an event spans over two different months it is only appearing in the month of the start date. I'm stuck on how to show it in the month of the finish date as well. For example, if I have an event with a start date of 19/03/2014 and a finish date of 19/04/2013 it should appear in both the month of March and April.
I am using the below:
// Get chosen month to display from URL
$events_month = sanitize_text_field($_GET["month"]);
$events_year = sanitize_text_field($_GET["year"]);
// Convert chosen month to display to a timestamp
$ts = strtotime("$events_month $events_year");
// Create chosen month start end end dates to use for query
$month_start_date = date('Ym01', $ts);
$month_end_date = date('Ymt', $ts);
$args = array(
'post_type' => 'events',
'posts_per_page' => 50,
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'start_date',
'meta_query' => array(
array(
'key' => 'start_date',
'value' => array($month_start_date, $month_end_date),
'type' => 'numeric',
'compare' => 'BETWEEN'
)
)
);
$events = new WP_Query($args);