add special

This commit is contained in:
argoexpert press
2025-05-29 00:59:59 +03:00
parent f2d7deeedf
commit 1b83816191
13 changed files with 377 additions and 17 deletions

39
category-forest.php Normal file
View File

@@ -0,0 +1,39 @@
<?php get_header( 'forest' ); ?>
<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
$current_category = get_queried_object();
$paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1; // Защита через absint()
$args = [
'post_type' => 'post',
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => get_option('posts_per_page'),
'ignore_sticky_posts' => true,
'no_found_rows' => false // Обязательно для пагинации!
];
// Обработка родительских/дочерних рубрик
if (!$current_category->parent) {
$child_categories = get_term_children($current_category->term_id, 'category');
$args['category__in'] = array_merge([$current_category->term_id], (array)$child_categories);
} else {
$args['cat'] = $current_category->term_id;
}
$query = new WP_Query($args);
?>
<?php get_template_part('partials/post-list', null, ['query' => $query]); ?>
</div>
<?php custom_pagination(); ?>
</div>
<?php get_footer( 'forest' ); ?>