add subtemplates and block promo smm
This commit is contained in:
@@ -50,18 +50,54 @@ function mob_block($template){
|
||||
}
|
||||
|
||||
|
||||
//свой шаблон для категории
|
||||
add_filter('category_template', function (){
|
||||
|
||||
$category = get_queried_object();
|
||||
$parent_id = $category->category_parent; // ID родителя
|
||||
|
||||
$template = array(); //массив для поиска шаблонов
|
||||
|
||||
$templates[] = "category-{$category->slug}.php";
|
||||
$templates[] = "category-{$category->term_id}.php";
|
||||
|
||||
if ($parent_id > 0){
|
||||
|
||||
$parent = get_category($parent_id);
|
||||
$templates[] = "category-{$parent->slug}.php";
|
||||
$templates[] = "category-{$parent->term_id}.php";
|
||||
|
||||
}
|
||||
|
||||
$templates[] = 'category.php';
|
||||
|
||||
return locate_template($templates);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
//свой шаблон для категории
|
||||
add_filter( 'single_template', function ( $single_template ) {
|
||||
|
||||
|
||||
$category = (array) get_the_category();
|
||||
|
||||
foreach( (array) get_the_category() as $cat ) {
|
||||
|
||||
if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
|
||||
return TEMPLATEPATH . "/single-{$cat->slug}.php";
|
||||
|
||||
}
|
||||
|
||||
return $single_template;
|
||||
foreach( $category as $cat ) {
|
||||
|
||||
if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ){
|
||||
return TEMPLATEPATH . "/single-{$cat->term_id}.php";
|
||||
}
|
||||
|
||||
$parent_id = $cat->parent; // шаблон гл рубрики
|
||||
|
||||
if ($parent_id > 0){
|
||||
$parent = get_category($parent_id);
|
||||
if (file_exists(TEMPLATEPATH . "/single-{$parent->term_id}.php") )
|
||||
return TEMPLATEPATH . "/single-{$parent->term_id}.php";
|
||||
}
|
||||
|
||||
}
|
||||
return $single_template;
|
||||
|
||||
|
||||
}, PHP_INT_MAX, 2 );
|
||||
|
||||
Reference in New Issue
Block a user