Files
agroexpert/rfo/category-end.php

48 lines
1.7 KiB
PHP
Raw Normal View History

2025-06-19 16:12:53 +03:00
<?php
/**
* Category Block Template
*
* @param array $args {
* @type string $category Slug рубрики (по умолчанию 'rfo')
* @type string $title Заголовок блока (по умолчанию 'Интервью')
* @type int $posts_count Количество постов (по умолчанию 1)
* }
*/
// Извлекаем параметры
$category = isset($args['category']) ? $args['category'] : 'rfo';
$title = isset($args['title']) ? $args['title'] : 'РФО';
2025-06-21 15:37:29 +03:00
$wrapper = isset($args['wrapper']) ? $args['wrapper'] : 'article-item-wrapper__rfo';
2025-06-19 16:12:53 +03:00
$style = isset($args['style']) ? $args['style'] : 0;
$posts_count = isset($args['posts_count']) ? $args['posts_count'] : 1;
?>
<div class="custom-category-block" data-category="<?php echo esc_attr($category); ?>">
<?php
$query_args = array(
'category_name' => $category,
'posts_per_page' => $posts_count,
'orderby' => 'date',
'order' => 'DESC'
);
$query = new WP_Query($query_args);
if ($query->have_posts()) : ?>
2025-06-21 15:37:29 +03:00
<div class="<?=$wrapper?>">
2025-06-19 16:12:53 +03:00
<div class="land-cart-title">
<div class="land-cart-title__text"><?php echo esc_html($title); ?></div>
<div class="land-cart-title__arrow"></div>
</div>
<div class="article-item-rfo">
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?get_template_part( 'content', 'post-rfo', [ 'class'=>'article-item-rfo '.$style ] );?>
<?php endwhile; ?>
</div>
</div>
<?php endif;
wp_reset_postdata(); ?>
</div>