Files
vij/single.php

181 lines
6.1 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;
2024-01-15 20:18:49 +03:00
$category_id = $post_category->term_id;
$category_name = $post_category->name;
$category_link = get_category_link($category_id);
break;
2024-01-10 19:09:03 +03:00
}
}
} else {
2024-01-15 20:18:49 +03:00
$pets_cat = false;
2024-01-10 19:09:03 +03:00
}
2024-01-15 20:18:49 +03:00
$post_id = get_the_ID();
2024-01-10 19:09:03 +03:00
?>
<?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
2024-01-15 20:18:49 +03:00
<?php
2021-09-18 01:30:09 +03:00
2024-01-10 19:09:03 +03:00
if ( $pets_cat ):?>
2024-01-15 20:18:49 +03:00
<?echo "<!-- pets: $category_name-->"?>
2024-01-10 19:09:03 +03:00
<ul id="nav_content">
<li><a href="<?=get_site_url()?>/category/pets">Питомцы</li>
<li>-<li>
2024-01-15 20:18:49 +03:00
<li><a href="<?=$category_link?>"><?echo $category_name;?></a></li>
2024-01-10 19:09:03 +03:00
<li>-<li>
<li><?=mb_substr(get_the_title(), 0, 50);?>...</li>
</ul>
2024-01-15 20:18:49 +03:00
<?else:
$category = get_the_category();
$category_id = $category[0]->term_id;
$category_name = $category['0']->name;
$category_link = get_category_link($category_id);?>
2024-01-10 19:09:03 +03:00
<ul id="nav_content">
<li><a href="<?=get_site_url()?>">Главная</li>
<li>-<li>
2024-01-15 20:18:49 +03:00
<li><a href="<?=$category_link?>"><?=$category_name;?></a></li>
2024-01-10 19:09:03 +03:00
<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">
2024-01-15 20:18:49 +03:00
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category_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();
2024-04-04 21:44:28 +03:00
if ( ! empty ( $author ) AND $author !== 'vetandlife.ru'):
$author_bio = get_the_author_meta('description', $author_id);?>
2021-09-20 01:07:53 +03:00
<div class="post_author">
2022-02-21 20:11:03 +03:00
Автор: <?=the_author_posts_link()?>
2024-04-04 21:44:28 +03:00
<?if (!empty($author_bio)):?>
<div class="post_author_sub"><?=$author_bio?></div>
<?endif?>
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;">
2024-01-18 16:42:39 +03:00
<?if ( $pets_cat ):?>
<p>Читайте нас в <span class="promo-telega"><a href="https://t.me/pitomcy_vetandlife" target="_blank">Telegram</a></span></p>
<?else:?>
<p>Читайте нас в <span class="promo-telega"><a href="https://t.me/ViZHuvizh" target="_blank">Telegram</a></span></p>
<?endif?>
2023-12-15 16:52:30 +03:00
</div>
2022-03-14 11:33:43 +03:00
<div class="post_panel_info">
<div class="post_panel_info_sub">
2024-01-18 16:42:39 +03:00
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category_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
2024-04-04 21:44:28 +03:00
<!-- Yandex.RTB R-A-4145099-6 -->
<div id="yandex_rtb_R-A-4145099-6"></div>
2023-12-15 16:52:30 +03:00
<script>
2024-04-04 21:44:28 +03:00
window.yaContextCb.push(()=>{
Ya.Context.AdvManager.render({
"blockId": "R-A-4145099-6",
"renderTo": "yandex_rtb_R-A-4145099-6"
})
})
2023-12-15 16:52:30 +03:00
</script>
2024-05-29 10:19:39 +03:00
<div id="unit_102382"><a href="https://smi2.ru/" >Новости СМИ2</a></div>
<script type="text/javascript" charset="utf-8">
(function() {
var sc = document.createElement('script'); sc.type = 'text/javascript'; sc.async = true;
sc.src = '//smi2.ru/data/js/102382.js'; sc.charset = 'utf-8';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(sc, s);
}());
</script>
2024-04-04 21:44:28 +03:00
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