21 lines
903 B
PHP
21 lines
903 B
PHP
<?php
|
|
|
|
add_filter('category_template', function($template) {
|
|
$current_category = get_queried_object();
|
|
|
|
// Только родительские рубрики (их дочерние подрубрики подхватятся автоматически)
|
|
$target_parent_slugs = ['forest', 'rfo']; // Только slug родительских рубрик
|
|
|
|
// Получаем родительскую рубрику
|
|
$parent_category = $current_category->parent
|
|
? get_category($current_category->parent)
|
|
: $current_category;
|
|
|
|
// Если текущая или родительская рубрика в списке
|
|
if (in_array($parent_category->slug, $target_parent_slugs)) {
|
|
$new_template = locate_template("category-{$parent_category->slug}.php");
|
|
if ($new_template) return $new_template;
|
|
}
|
|
|
|
return $template;
|
|
}); |