<?php get_header(); ?>
<div class="content-middle articles-wrapper">
    <?php get_template_part('partials/rubrics-mobile'); ?>
    <div class="section-title desktop">
        <?php if (is_category()) : ?>
            <h1 class="section-title__title"><?= get_queried_object()->name ?></h1>
        <?php endif; ?>
    </div>
    <div class="articles-preview">
        <?php
        $paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
        $counter = 0;
        $args = array(
            'post_type' => 'post',
            'posts_per_page' => 10,
            'paged' => $paged,
            'category__in' => get_queried_object_id()
        );
        $query = new WP_Query($args);
        ?>
        
        <? if ($query->have_posts()) : ?>
            <? while ($query->have_posts()) : $query->the_post(); ?>
                <? $counter++;
                $formatted_date = format_event_date(); ?>
                <a href="<? the_permalink(); ?>">
                    <div class="article-item">
                        <?if (has_post_thumbnail()):?>
                        <div class="interview-item__image-container">
                            <?//=show_post_image(); ?>
                            <?=render_webp_picture_by_post( null, 'news-list-picture'); ?>
                            <button class="item-video__button subtitle-20">
                                <img src="<?= get_asset('icons/play.svg') ?>" alt="" /> Интервью
                            </button>
                        </div>
                        <?endif?>
                        <div class="article-item__text">
                            <div class="article-time">
                                <img src="<?= get_asset('icons/time.svg') ?>" alt="" />
                                <time><?= $formatted_date; ?></time>
                            </div>
                            <a href="<? the_permalink(); ?>" class="subtitle-16 article-item__link">
                                <?= the_title() ?>
                            </a>
                        </div>
                    </div>
                </a>
            <? endwhile; ?>
            <? if ($counter == 4) : ?>
                <div class="banner-middle desktop">
                    <?php if (function_exists('banners_conf_display')) banners_conf_display('content_banner_desktop'); ?>
                </div>
                <div class="banner-middle mobile">
                    <?php if (function_exists('banners_conf_display')) banners_conf_display('content_banner_mobile'); ?>
                </div>
            <? endif; ?>
        <? endif; ?>
        <a href="<?= home_url(); ?>" class="articles-preview__show-next mobile">На главную</a>
    </div>
    <? custom_pagination(); ?>



    </div>
    
<?php get_footer(); ?>