Initial commit
This commit is contained in:
49
widgets/upcoming-events-widget-template.php
Normal file
49
widgets/upcoming-events-widget-template.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<div class="content-sidebar">
|
||||
<div class="content-sidebar-top">
|
||||
<div class="content-sidebar__title subtitle-20">Календарь мероприятий</div>
|
||||
<div id="calendar"></div>
|
||||
<div class="upcoming-events">
|
||||
<h3 class="upcoming-events__title subtitle-16">Ближайшие мероприятия</h3>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'post',
|
||||
'category_name' => 'events',
|
||||
'posts_per_page' => 3,
|
||||
// 'meta_key' => 'event_date', // Ключ кастомного поля с датой мероприятия
|
||||
// 'orderby' => 'meta_value_num',
|
||||
'order' => 'ASC',
|
||||
// 'meta_query' => array(
|
||||
// array(
|
||||
// 'key' => 'event_date',
|
||||
// 'value' => $current_date,
|
||||
// 'compare' => '>=', // Показываем мероприятия, начиная с текущей даты
|
||||
// 'type' => 'NUMERIC',
|
||||
// ),
|
||||
// ),
|
||||
);
|
||||
|
||||
$query = new WP_Query($args);
|
||||
|
||||
if ($query->have_posts()) {
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
$formatted_date = format_event_date();
|
||||
?>
|
||||
<div class="upcoming-event">
|
||||
<div class="article-time">
|
||||
<img src="<?= get_asset('/icons/time.svg'); ?>" alt="" /><?php echo $formatted_date; ?>
|
||||
</div>
|
||||
<a class="link" href="<?php the_permalink(); ?>">
|
||||
<?php the_title(); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
wp_reset_postdata();
|
||||
} else {
|
||||
echo '<p>Нет предстоящих мероприятий.</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user