add subtemplates and block promo smm

This commit is contained in:
arlemp@selectel.ru
2021-11-11 19:30:47 +03:00
parent 30b9d5c83c
commit 9aefc76b6e
6 changed files with 66 additions and 13 deletions

View File

@@ -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 ) {
foreach( $category as $cat ) {
if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
return TEMPLATEPATH . "/single-{$cat->slug}.php";
if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ){
return TEMPLATEPATH . "/single-{$cat->term_id}.php";
}
}
$parent_id = $cat->parent; // шаблон гл рубрики
return $single_template;
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 );

View File

@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?php wp_title('|', true, 'right');?><?=get_bloginfo('name')?></title>
<link rel="stylesheet" href="<?php echo get_stylesheet_uri();?>?ver=52">
<link rel="stylesheet" href="<?php echo get_stylesheet_uri();?>?ver=53">
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet">
<script type='text/javascript' src="<?php echo get_stylesheet_directory_uri()?>/scripts/jquery-3.6.0.min.js"></script>
<script type='text/javascript' src="<?php echo get_stylesheet_directory_uri()?>/scripts/burger-menu.js?ver=9"></script>

View File

@@ -47,7 +47,9 @@
<?endif?>
<div class="fulltext">
<?the_content();?>
<p>Свежие отраслевые новости на нашем канале в <a href="https://t.me/ViZHuvizh" target="_blank">Telegram</a></p>
</div>
<div class="promo-agregators">
<p>Свежие отраслевые новости на нашем канале в <span class="promo-telega"><a href="https://t.me/ViZHuvizh" target="_blank">Telegram</a></span></p>
<p>Добавьте «Ветеринарию и жизнь» в избранное в <a href="https://yandex.ru/news/?favid=254162793" target="_blank"><span style="color:red; font-weight: bold;">Я</span><span style="font-weight: bold; color:black;">НДЕКС.НОВОСТИ</span></a></p>
</div>
<!--<p><small class="text-muted"><?php the_tags('');?></small></p> -->

View File

@@ -678,6 +678,21 @@ a{
}
.promo-agregators{
margin-top: 28px;
padding: 32px 28px 32px 28px;
background: #E9EAEB;
}
.promo-agregators a{
color: #2D9CDB;
}
.promo-telega{
font-weight: bold;
text-transform: uppercase;
}
.wp-block-image IMG{
/** object-fit: cover; */