add special
This commit is contained in:
21
inc/special.php
Normal file
21
inc/special.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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;
|
||||
});
|
||||
Reference in New Issue
Block a user