64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?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'] : '';
|
|
$wrapper = isset($args['wrapper']) ? $args['wrapper'] : 'article-item-wrapper__rfo';
|
|
$style = isset($args['style']) ? $args['style'] : '';
|
|
$has_video = isset($args['has_video']) ? $args['has_video'] : false;
|
|
|
|
if ( $style == 'short' ){
|
|
$wrapper = 'article-short-wrapper__rfo';
|
|
$color_style = 'article-short-rfo';
|
|
$short = true;
|
|
$template = 'short-rfo';
|
|
} else {
|
|
$short = false;
|
|
$wrapper = 'article-item-wrapper__rfo';
|
|
$template = 'post-rfo';
|
|
if ($style == '') {
|
|
$color_style = 'article-item-rfo';
|
|
} else {
|
|
$color_style = 'article-item-rfo '.$style;
|
|
}
|
|
}
|
|
|
|
|
|
$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()) : ?>
|
|
|
|
<?php while ($query->have_posts()) : $query->the_post(); ?>
|
|
<?get_template_part( 'content', $template,
|
|
[
|
|
'class'=>$color_style,
|
|
'title' => $title,
|
|
'title_link' => get_category_link(get_category_by_slug($category)),
|
|
'has_video' => $has_video
|
|
]);?>
|
|
<?php endwhile; ?>
|
|
|
|
<?php endif;
|
|
|
|
wp_reset_postdata(); ?>
|
|
</div>
|