add special
This commit is contained in:
39
category-forest.php
Normal file
39
category-forest.php
Normal 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' ); ?>
|
||||
Reference in New Issue
Block a user