Files
agroexpert/widgets/upcoming-events-widget-template.php
2024-09-06 10:56:22 +03:00

47 lines
1.9 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="content-sidebar">
<div class="content-sidebar-top">
<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' => 'DESC',
// '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>