add correct meta calendar
This commit is contained in:
@@ -5,17 +5,11 @@
|
||||
$posts = get_posts( array(
|
||||
'numberposts' => 3,
|
||||
'category' => 61, // 61 - мероприятия
|
||||
'orderby' => 'date',
|
||||
'orderby' => 'meta_value',
|
||||
'order' => 'ASC',
|
||||
|
||||
'date_query' => array(
|
||||
array(
|
||||
'after' => '3 days ago',
|
||||
),
|
||||
),
|
||||
|
||||
'meta_query' => array(array('key' => 'startevent')),
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish, future',
|
||||
//'post_status' => 'publish, future',
|
||||
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
|
||||
) );
|
||||
|
||||
@@ -29,7 +23,8 @@ if( $posts ):?>
|
||||
?>
|
||||
|
||||
<div class="event">
|
||||
<div class="news_date"><?the_time('j F Y');?></div>
|
||||
<?$eventdate = get_post_meta( $post->ID, 'startevent', true );?>
|
||||
<div class="news_date"><?=date_i18n('j F Y', strtotime($eventdate))?></div>
|
||||
<a href="<?php the_permalink(); ?>"><?php the_title();?></a>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ define("COOK_VALUE", "7895");
|
||||
|
||||
require get_template_directory().'/src/calend-block.php';
|
||||
require get_template_directory().'/src/calendar.php';
|
||||
require ABSPATH.'vendor/masterforweb/db_lite/db_lite.php';
|
||||
|
||||
db_config(DB_NAME, 'mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD);
|
||||
|
||||
# регистрируем меню
|
||||
register_nav_menus(array(
|
||||
@@ -265,3 +268,35 @@ if (!function_exists('view')){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function arr_to_in($items){
|
||||
|
||||
$in = array();
|
||||
|
||||
foreach ($items as $item){
|
||||
|
||||
$in[] = $item['post_id'];
|
||||
}
|
||||
|
||||
return $in;
|
||||
|
||||
}
|
||||
|
||||
function str_to_in($items){
|
||||
|
||||
$in = '';
|
||||
|
||||
foreach ($items as $item){
|
||||
|
||||
if ($in !== '') {
|
||||
$in .= ',';
|
||||
}
|
||||
|
||||
|
||||
$in .= $item['post_id'];
|
||||
}
|
||||
|
||||
return $in;
|
||||
|
||||
}
|
||||
@@ -69,11 +69,17 @@ $nn = 0;?>
|
||||
|
||||
<?php wp_reset_postdata();?>
|
||||
|
||||
<div class="publ-to-main">
|
||||
<button class="more_button" onclick="location.href='<?=get_category_link(2)?>/page/2'" type="button">
|
||||
Показать ещe</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?get_template_part( '/blocks/opinion', null, ['subclass' => 'mob-lite']);?>
|
||||
<?get_template_part( '/blocks/citata', null, ['subclass' => 'mob-lite']);?>
|
||||
<?get_template_part( '/blocks/mosts', null, ['subclass' => 'mob-lite']);?>
|
||||
|
||||
<div class="publ-to-main"><a href="<?=get_category_link(2)?>/page/2"><span class="go-to-main">Показать ещe</span></a></div>
|
||||
|
||||
|
||||
</div> <!-- end content -->
|
||||
|
||||
16
single.php
16
single.php
@@ -66,7 +66,11 @@
|
||||
|
||||
<?php include get_template_directory().'/blocks/moread.php';?>
|
||||
|
||||
<div class="publ-to-main"><a href="<?=get_site_url()?>"> <span class="arrow-go-main"><</span> <span class="go-to-main">На главную</span></a></div>
|
||||
<div class="publ-to-main">
|
||||
<button class="more_button" onclick="location.href='<?=get_site_url()?>/page/2'" type="button">
|
||||
На главную</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@@ -74,14 +78,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php get_footer();?>
|
||||
|
||||
@@ -1,42 +1,64 @@
|
||||
<?php
|
||||
|
||||
setlocale(LC_ALL, 'ru_RU');
|
||||
date_default_timezone_set('Europe/Moscow');
|
||||
|
||||
function calend_block($month, $year, $script=false){
|
||||
|
||||
$args = array(
|
||||
$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'
|
||||
";
|
||||
|
||||
|
||||
$items = db_get($find_sql);
|
||||
|
||||
$ins = str_to_in($items);
|
||||
|
||||
if ($ins !== '') {
|
||||
|
||||
$posts = db_get("
|
||||
SELECT ID, post_date, post_title FROM `wp_posts` WHERE ID IN ($ins)
|
||||
");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** $args = array(
|
||||
'numberposts' => -1,
|
||||
'category' => 61, // 61 - мероприятия
|
||||
'orderby' => 'date',
|
||||
'order' => 'ASC',
|
||||
|
||||
'date_query' => array(
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'after' => array( // после этой даты
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'day' => 1,
|
||||
'key' => 'startevent',
|
||||
'value' => array( "$year-$month-01T00:00:00", "$year-$month-31T23:59:59" ),
|
||||
'compare' => 'BETWEEN',
|
||||
'type' => 'DATE'
|
||||
),
|
||||
'before' => array( // до этой даты
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'day' => 31,
|
||||
),
|
||||
// 'inclusive'=> true
|
||||
)
|
||||
),
|
||||
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish, future',
|
||||
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
|
||||
);*/
|
||||
|
||||
$args = array(
|
||||
'numberposts' => -1,
|
||||
'post__in' => $ins
|
||||
);
|
||||
|
||||
$posts = get_posts($args);
|
||||
//$posts = get_posts($args);
|
||||
|
||||
$events = [];
|
||||
|
||||
if (is_array($posts)){
|
||||
|
||||
foreach ($posts as $post){
|
||||
$key = date('d.m.Y', strtotime($post->post_date));
|
||||
$events[$key]['text'] = $post->post_title;
|
||||
$events[$key]['link'] = get_permalink($post->ID);
|
||||
$eventdate = get_post_meta($post['ID'], 'startevent', true);
|
||||
$key = date('d.m.Y', strtotime($eventdate));
|
||||
$events[$key]['text'] = $post['post_title'];
|
||||
$events[$key]['link'] = get_permalink($post['ID']);
|
||||
|
||||
}
|
||||
|
||||
}?>
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ class Calendar
|
||||
*/
|
||||
public static function getMonth($month, $year, $events = array())
|
||||
{
|
||||
|
||||
|
||||
$months = array(
|
||||
1 => 'Январь',
|
||||
2 => 'Февраль',
|
||||
@@ -67,7 +69,7 @@ class Calendar
|
||||
$class = '';
|
||||
}
|
||||
|
||||
$event_show = false;
|
||||
/** $event_show = false;
|
||||
$event_text = '';
|
||||
$event_link = '';
|
||||
if (!empty($events)) {
|
||||
@@ -96,14 +98,24 @@ class Calendar
|
||||
$event_link = $text['link'];
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
if ($day < 10)
|
||||
$day_str = "0$day";
|
||||
else
|
||||
$day_str = $day;
|
||||
|
||||
$arr_key = "$day_str.$month.$year";
|
||||
|
||||
|
||||
|
||||
//if ($event_show) {
|
||||
if (isset($events[$arr_key])) {
|
||||
|
||||
if ($event_show) {
|
||||
|
||||
$out.= '<td class="calendar-day ' . $class . ' calendar-event">';
|
||||
if (!empty($event_text)) {
|
||||
$out.= '<div class="calendar-popup" ><a href="'.$event_link.'" title="'.$event_text.'">'.$day.'</a></div>';
|
||||
}
|
||||
$out.= '<div class="calendar-popup" ><a href="'.$events[$arr_key]['link'].'" title="'.$events[$arr_key]['text'].'">'.$day.'</a></div>';
|
||||
|
||||
$out.= '</td>';
|
||||
} else {
|
||||
$out.= '<td class="calendar-day ' . $class . '">' . $day . '</td>';
|
||||
|
||||
20
style.css
20
style.css
@@ -387,6 +387,26 @@ a{
|
||||
height: 55px;
|
||||
}
|
||||
|
||||
.more_button {
|
||||
background: #FFFFFF;
|
||||
box-sizing: border-box;
|
||||
border-radius: 47px;
|
||||
border: 1px solid #171717;
|
||||
color: #171717;
|
||||
padding: 10px 28px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
font-size: 16px;
|
||||
font-size: 11px;
|
||||
line-height: 110%;
|
||||
height: 45px;
|
||||
margin-top: 22px;
|
||||
|
||||
}
|
||||
|
||||
.vazh{
|
||||
font-size: 9px;
|
||||
text-transform: uppercase;
|
||||
|
||||
Reference in New Issue
Block a user