Files
agroexpert/category-rfo.php
2025-06-22 14:09:09 +03:00

57 lines
2.0 KiB
PHP
Raw 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.

<?php get_header( 'rfo' ); ?>
<div class="content-rfo">
<? $current_category = get_queried_object();
if ($current_category->name !== 'РФО') {
get_template_part( 'rfo/breadcrumbs-rfo' );
}
$has_video = ($current_category->slug === 'opinion') ? true : false;
?>
<div class="rfo__rubric"><?=$current_category->name; ?></div>
<div class="articles-columns-rfo">
<?php
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
// Проверяем, есть ли у текущей рубрики родительская рубрика
if ($current_category->parent == 0) {
// Это родительская рубрика - получаем все её подрубрики
$child_categories = get_categories(array(
'child_of' => $current_category->term_id,
'hide_empty' => false
));
// Собираем ID всех подрубрик + ID текущей родительской
$category_ids = array($current_category->term_id);
foreach ($child_categories as $child) {
$category_ids[] = $child->term_id;
}
$args = array(
'post_type' => 'post',
'posts_per_page' => 14,
'paged' => $paged,
'category__in' => $category_ids
);
} else {
// Это подрубрика - выводим только её посты
$args = array(
'post_type' => 'post',
'posts_per_page' => 14,
'paged' => $paged,
'category__in' => array($current_category->term_id)
);
}
$query = new WP_Query($args);
?>
<?php get_template_part('rfo/post-list', null, ['query' => $query , 'has_video' => $has_video]); ?>
</div>
<?php custom_pagination( null, 'pagination pagination__rfo' ); ?>
</div>
<?php get_footer( 'rfo' ); ?>