Files
vij/category-3.php
2026-02-07 11:05:31 +03:00

129 lines
4.0 KiB
PHP
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* The main template file.
*
*/
require TEMPLATEPATH.'/helpers/number_title.php';
get_header();?>
<div id="content">
<ul id="nav_content">
<li><a href="<?=get_home_url()?>">Главная</a></li>
<li> - <?single_cat_title()?></li>
</ul>
<h1 class="my-4"><?single_cat_title()?></h1>
<div class="numbers-anons">
<p>Федеральное отраслевое издание «Ветеринария и жизнь» выходит с 2017 года и является крупнейшим периодическим печатным изданием в сфере сельского хозяйства и ветеринарии. К скачиванию доступен архив за все годы существования издания.</p>
</div>
<?php
$page = get_query_var('paged');
$curryear = date('Y');
$year_params = [
'posts_per_page' => -1,
'category' => 3, // 19 - архив газеты,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'post',
'suppress_filters' => true
];
if ($page == 0) {
$page = 1;
$numbers_year = $curryear;
} else {
$numbers_year = $curryear - ($page - 1);
}
$curr_params = $year_params;
$curr_params['year'] = $numbers_year;
$posts = get_posts($curr_params);
if (count($posts) == 0) {
$numbers_year = $numbers_year - 1;
$curr_params = $year_params;
$curr_params['year'] = $numbers_year;
$posts = get_posts($curr_params);
}
if (count($posts) > 0): ?>
<div class="numbers-year-title"><?php echo $numbers_year; ?></div>
<div class="mini-card-block">
<?php foreach($posts as $post):
setup_postdata($post);
// Обработка ошибки в функции number_info()
$curr_number = '';
try {
$curr_number = number_info(get_the_title());
} catch (Exception $e) {
// Логируем ошибку, но не прерываем выполнение
error_log('Error in number_info: ' . $e->getMessage());
$curr_number = ''; // или значение по умолчанию
}
?>
<div class="mini-card-number">
<?php if (has_post_thumbnail()) : ?>
<div class="mini-card-img">
<a href="<?php the_permalink(); ?>">
<img class="mini-card-number-img" width="147" style="width: 147px;" src="<?php echo get_the_post_thumbnail_url(null, 'large'); ?>" alt="<?php the_title(); ?>">
</a>
<?php if(has_tag('видео')): ?>
<span class="play-card"></span>
<?php endif; ?>
</div>
<?php endif; ?>
<h2 class="mini-card-number-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
</div>
<?php endforeach; ?>
</div> <!--//end minicard block -->
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<div class="numbers-anons">
<p>Номера газеты выкладываются в общий доступ через месяц после выхода.</p>
<p>Заказать свежий номер можно на Wildberries по <u><a href="https://www.wildberries.ru/catalog/482667738/detail.aspx?targetUrl=EX" target="_blank">ссылке</a></u></p>
</div>
<div class="pagination-wrapper">
<nav class="navigation pagination" role="navigation" aria-label="Записи">
<div class="nav-links">
<?$np = 0;
for ($y = $curryear; $y > 2016; $y--):?>
<?$np++?>
<?if ($y == $numbers_year):?>
<span aria-current="page" class="page-numbers current"><?=$y?></span>
<?else:?>
<a class="page-numbers" href="https://vetandlife.ru/category/arkhiv/page/<?=$np?>/"><?=$y?></a>
<?endif?>
<?endfor?>
</div>
</nav>
</div>
</div>
<?php get_footer(); ?>