This commit is contained in:
2021-11-20 15:24:05 +03:00
parent 3569512aa5
commit 0cf65e0587
2 changed files with 10 additions and 3 deletions

View File

@@ -5,10 +5,17 @@
function calend_block($month, $year, $script=false){ function calend_block($month, $year, $script=false){
if (strlen($month) == 1){
$str_month = "0$month";
}
else{
$str_month = "$month";
}
$find_sql = " $find_sql = "
SELECT `post_id` SELECT `post_id`
FROM `wp_postmeta` 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){ foreach ($posts as $post){
$eventdate = get_post_meta($post['ID'], 'startevent', true); $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]['text'] = $post['post_title'];
$events[$key]['link'] = get_permalink($post['ID']); $events[$key]['link'] = get_permalink($post['ID']);

View File

@@ -9,6 +9,6 @@ require '/vhosts/beta/wp-load.php';
if (isset($_GET['month']) and $_GET['year']){ if (isset($_GET['month']) and $_GET['year']){
calend_block($_GET['month'], $_GET['year']); calend_block(trim($_GET['month']), trim($_GET['year']));
} }