diff --git a/src/calend-block.php b/src/calend-block.php index 8b7b54f..b6bc171 100644 --- a/src/calend-block.php +++ b/src/calend-block.php @@ -5,10 +5,17 @@ function calend_block($month, $year, $script=false){ + if (strlen($month) == 1){ + $str_month = "0$month"; + } + else{ + $str_month = "$month"; + } + $find_sql = " SELECT `post_id` FROM `wp_postmeta` - WHERE `meta_key` = 'startevent' AND `meta_value` BETWEEN '$year-$month-01T00:00:00' AND '$year-$month-31T23:59:59' + WHERE `meta_key` = 'startevent' AND `meta_value` BETWEEN '$year-$str_month-01T00:00:00' AND '$year-$str_month-31T23:59:59' "; @@ -54,7 +61,7 @@ function calend_block($month, $year, $script=false){ foreach ($posts as $post){ $eventdate = get_post_meta($post['ID'], 'startevent', true); - $key = date('d.m.Y', strtotime($eventdate)); + $key = date('d.n.Y', strtotime($eventdate)); $events[$key]['text'] = $post['post_title']; $events[$key]['link'] = get_permalink($post['ID']); diff --git a/src/eventcalendar.php b/src/eventcalendar.php index e5a2e06..5548b16 100644 --- a/src/eventcalendar.php +++ b/src/eventcalendar.php @@ -9,6 +9,6 @@ require '/vhosts/beta/wp-load.php'; if (isset($_GET['month']) and $_GET['year']){ - calend_block($_GET['month'], $_GET['year']); + calend_block(trim($_GET['month']), trim($_GET['year'])); }