Files
vij/single.php

169 lines
5.4 KiB
PHP
Raw Normal View History

2024-01-10 19:09:03 +03:00
<?php
// Указываем ID или slug основной рубрики
$pets_cat = false;
$pets_category_id_or_slug = 'pets';
2021-09-18 01:30:09 +03:00
2024-01-10 19:09:03 +03:00
// Получаем объект основной рубрики
$pets_category = get_term_by('slug', $pets_category_id_or_slug, 'category');
2021-09-20 01:07:53 +03:00
2024-01-10 19:09:03 +03:00
$post_categories = get_the_terms(get_the_ID(), 'category');
if ($post_categories && !is_wp_error($post_categories)) {
foreach ($post_categories as $post_category) {
if ($post_category->parent == $pets_category->term_id) {
$pets_cat = true;
break; // Мы уже нашли подходящую подрубрику, можно прервать цикл
}
}
} else {
$pets_cat = false;
}
echo "<!-- pets_cat: $pets_cat -->";
?>
<?php
if ( $pets_cat ){
get_header( 'pets' );
} else {
get_header();
}?>
2021-09-24 23:18:38 +03:00
<div id="content">
2021-09-18 01:30:09 +03:00
<?//while(have_posts()):?>
2021-09-24 23:18:38 +03:00
<?the_post();?>
2021-09-18 01:30:09 +03:00
<?php $category = get_the_category();
$category_id = $category[0]->term_id;
$category_link = get_category_link($category_id);
2021-11-11 23:15:08 +03:00
$post_id = get_the_ID();
2021-09-18 01:30:09 +03:00
2024-01-10 19:09:03 +03:00
if ( $pets_cat ):?>
<ul id="nav_content">
<li><a href="<?=get_site_url()?>/category/pets">Питомцы</li>
<li>-<li>
<li><a href="<?=$category_link?>"><?=$category['0']->name;?></a></li>
<li>-<li>
<li><?=mb_substr(get_the_title(), 0, 50);?>...</li>
</ul>
<?else:?>
<ul id="nav_content">
<li><a href="<?=get_site_url()?>">Главная</li>
<li>-<li>
<li><a href="<?=$category_link?>"><?=$category['0']->name;?></a></li>
<li>-<li>
<li><?=mb_substr(get_the_title(), 0, 50);?>...</li>
</ul>
<?endif?>
2021-09-24 23:18:38 +03:00
2021-09-18 01:30:09 +03:00
<div class="post_info">
2021-09-20 01:07:53 +03:00
<div class="post_info_sub">
2022-04-06 00:10:37 +03:00
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category['0']->name;?></a></span>, <nobr><?php the_time('j F Y, G:i');?></nobr>
2021-09-28 22:25:21 +03:00
</div>
2021-09-24 23:18:38 +03:00
<div class="post_info_sub post_info_social">
2021-10-09 22:59:32 +03:00
<?php include get_template_directory().'/blocks/social-share.php';?>
2021-09-20 01:07:53 +03:00
</div>
2021-09-18 01:30:09 +03:00
</div>
2022-01-11 23:06:02 +03:00
<div id="fulltext">
2021-09-28 22:25:21 +03:00
<h1 class="post-h1"><?php wp_title('');?></h1>
2021-09-24 23:18:38 +03:00
<?$author = get_the_author();
if ( ! empty ( $author ) AND $author !== 'vetandlife.ru'):?>
2021-09-20 01:07:53 +03:00
<div class="post_author">
2022-02-21 20:11:03 +03:00
Автор: <?=the_author_posts_link()?>
2021-09-20 01:07:53 +03:00
</div>
2021-09-24 23:18:38 +03:00
<?endif?>
2021-09-18 01:30:09 +03:00
<div class="publ_expert"><?php the_excerpt();?></div>
2021-09-24 23:18:38 +03:00
<?if ( has_post_thumbnail() ) :?>
2021-09-27 00:07:02 +03:00
<div id="post-img">
<img class="img-fluid rounded" src="<?php echo get_the_post_thumbnail_url(null, 'full');?>" alt="<?the_title();?>">
</div>
2021-09-24 23:18:38 +03:00
<div class="post_img_title"><?the_post_thumbnail_caption()?></div>
<?endif?>
2021-11-10 21:21:00 +03:00
<div class="fulltext">
2021-11-11 19:30:47 +03:00
<?the_content();?>
2021-11-10 21:21:00 +03:00
</div>
2023-12-15 16:52:30 +03:00
2023-12-22 22:28:05 +03:00
<div class="promo-agregators" style="text-align: center;">
2023-12-15 16:52:30 +03:00
<p>Читайте нас в <span class="promo-telega"><a href="https://t.me/ViZHuvizh" target="_blank">Telegram</a></span></p>
</div>
2022-03-14 11:33:43 +03:00
<div class="post_panel_info">
<div class="post_panel_info_sub">
2022-04-06 00:10:37 +03:00
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category['0']->name;?></a></span>, <nobr><?php the_time('j F Y, G:i');?></nobr>
2022-03-14 11:33:43 +03:00
</div>
<div class="post_panel_info_sub">
<!--Поделиться <i class="fas fa-share-square btn_soc_post"></i>--> <?php include get_template_directory().'/blocks/social-share.php';?>
</div>
</div>
2022-12-09 11:45:40 +03:00
<div class="promo-poll">
<strong>Какие новости интересны читателям «Ветеринарии и жизни»? <a href="https://vetandlife.ru/polls/opros-kakie-novosti-interesny-chitatelyam-veterinarii-i-zhizni/">Пройти опрос</a></strong>
</div>
2023-12-15 16:52:30 +03:00
2021-09-18 01:30:09 +03:00
<!--<p><small class="text-muted"><?php the_tags('');?></small></p> -->
2021-09-24 23:18:38 +03:00
<?//endwhile;?>
2021-09-18 01:30:09 +03:00
2023-12-15 16:52:30 +03:00
<div style="margin-top: 12px;"class="aQKhHt2390"></div>
<script>
window.k_init = window.k_init || [];
k_init.push({
id: 'aQKhHt2390',
type: 'bn',
domain: 'cchdbond.com',
refresh: false,
next: 0
});
var s = document.createElement('script');
s.setAttribute('async', true);
s.setAttribute('charset', 'utf-8');
s.setAttribute('data-cfasync', false);
s.src = 'https://cchdbond.com/qae0820f.js';
document.head && document.head.appendChild(s);
</script>
2021-09-20 01:07:53 +03:00
<?php include get_template_directory().'/blocks/yets.php';?>
2021-09-24 23:18:38 +03:00
<div id="tags">
<?php the_tags();?>
</div>
2021-09-18 01:30:09 +03:00
2022-01-11 23:06:02 +03:00
</div>
2021-09-18 01:30:09 +03:00
<?php include get_template_directory().'/blocks/moread.php';?>
2021-11-01 02:22:21 +03:00
<div class="publ-to-main">
<button class="more_button" onclick="location.href='<?=get_site_url()?>/page/2'" type="button">
На главную</button>
</div>
2021-09-20 01:07:53 +03:00
2021-11-01 02:22:21 +03:00
2021-09-18 01:30:09 +03:00
</div>
2024-01-10 19:09:03 +03:00
<?php
if ( $pets_cat ){
get_footer( 'pets' );
} else {
get_footer();
}?>
2021-09-18 01:30:09 +03:00