correct data

This commit is contained in:
2026-02-07 11:05:31 +03:00
parent 6ab9106be0
commit 09ef3e1d6d
12 changed files with 378 additions and 278 deletions

View File

@@ -42,9 +42,7 @@ if ( $random_posts ) {
<div class="pets-widget-maintitle"><a href="/pets">Питомцы</a></div> <div class="pets-widget-maintitle"><a href="/pets">Питомцы</a></div>
<a href="<?php the_permalink(); ?>"> <a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?> <?php if ( has_post_thumbnail() ) : ?>
<div>
<?php the_post_thumbnail('medium'); ?> <?php the_post_thumbnail('medium'); ?>
</div>
<?php endif; ?> <?php endif; ?>
<h3 class="pets-widget-title"><?php the_title(); ?></h3> <h3 class="pets-widget-title"><?php the_title(); ?></h3>
</a> </a>

View File

@@ -2,8 +2,8 @@
<a href="https://vk.com/vizhuvizh" target="_blank"><span class="socs soc-vk"></span></a> <a href="https://vk.com/vizhuvizh" target="_blank"><span class="socs soc-vk"></span></a>
<a href="https://t.me/ViZHuvizh" target="_blank"><span class="socs soc-tg"></span></a> <a href="https://t.me/ViZHuvizh" target="_blank"><span class="socs soc-tg"></span></a>
<a href="https://www.youtube.com/c/ВетеринарияиЖизнь" target="_blank"><span class="socs soc-rutube"></span></a> <a href="https://rutube.ru/channel/42943284/" target="_blank"><span class="socs soc-rutube"></span></a>
<a href="https://www.youtube.com/c/ВетеринарияиЖизнь" target="_blank"><span class="socs soc-dzen"></span></a> <a href="https://dzen.ru/vetandlife" target="_blank"><span class="socs soc-dzen"></span></a>
<!-- <div class="btn soc_vk"></div> <!-- <div class="btn soc_vk"></div>
<div class="soc_btn soc_fb"></div> <div class="soc_btn soc_fb"></div>

View File

@@ -23,95 +23,84 @@ get_header();?>
<h1 class="my-4"><?single_cat_title()?></h1> <h1 class="my-4"><?single_cat_title()?></h1>
<div class="numbers-anons"> <div class="numbers-anons">
<p>Федеральное отраслевое издание «Ветеринария и жизнь» выходит с 2017 года и является крупнейшим периодическим печатным изданием в сфере сельского хозяйства и ветеринарии. К скачиванию доступен архив за все годы существования издания.<br><br> <p>Федеральное отраслевое издание «Ветеринария и жизнь» выходит с 2017 года и является крупнейшим периодическим печатным изданием в сфере сельского хозяйства и ветеринарии. К скачиванию доступен архив за все годы существования издания.</p>
Номера газеты выкладываются в общий доступ через месяц после выхода.<br><br>
Заказать свежий номер можно на Wildberries по <u><a href="https://www.wildberries.ru/catalog/482667738/detail.aspx?targetUrl=EX" target="_blank">ссылке</a></u></p>
</div> </div>
<?php <?php
$page = get_query_var('paged'); $page = get_query_var('paged');
$curryear = date('Y'); $curryear = date('Y');
$year_params = [ $year_params = [
'posts_per_page' => -1, 'posts_per_page' => -1,
'category' => 3, // 19 - архив газеты, 'category' => 3, // 19 - архив газеты,
'orderby' => 'date', 'orderby' => 'date',
'order' => 'DESC', 'order' => 'DESC',
'post_type' => 'post', 'post_type' => 'post',
'suppress_filters' => true 'suppress_filters' => true
]; ];
if ($page == 0) { if ($page == 0) {
$page = 1; $page = 1;
$numbers_year = $curryear; $numbers_year = $curryear;
} } else {
else {
$numbers_year = $curryear - ($page - 1); $numbers_year = $curryear - ($page - 1);
} }
$curr_params = $year_params; $curr_params = $year_params;
$curr_params['year'] = $numbers_year; $curr_params['year'] = $numbers_year;
$posts = get_posts($curr_params); $posts = get_posts($curr_params);
if (count($posts) == 0) { if (count($posts) == 0) {
$numbers_year = $numbers_year - 1; $numbers_year = $numbers_year - 1;
$curr_params = $year_params; $curr_params = $year_params;
$curr_params['year'] = $numbers_year; $curr_params['year'] = $numbers_year;
$posts = get_posts($curr_params); $posts = get_posts($curr_params);
} }
?> if (count($posts) > 0): ?>
<div class="numbers-year-title"><?php echo $numbers_year; ?></div>
<?if (count($posts) > 0):?>
<div class="numbers-year-title"><?=$numbers_year?></div>
<div class="mini-card-block"> <div class="mini-card-block">
<?php foreach($posts as $post):
<?foreach($posts as $post):
setup_postdata($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 = ''; // или значение по умолчанию
}
?> ?>
<?$curr_number = number_info(get_the_title());?>
<div class="mini-card-number"> <div class="mini-card-number">
<?if ( has_post_thumbnail() ) :?> <?php if (has_post_thumbnail()) : ?>
<div class="mini-card-img"> <div class="mini-card-img">
<a href="<?the_permalink();?>"><img class="mini-card-number-img" width="147" style="width: 147px;" src="<?php echo get_the_post_thumbnail_url(null, 'large'); ?>" alt="<?the_title();?>"></a> <a href="<?php the_permalink(); ?>">
<?if( has_tag( 'видео' ) ):?> <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> <span class="play-card"></span>
<?endif?> <?php endif; ?>
</div> </div>
<?endif?> <?php endif; ?>
<h2 class="mini-card-number-title"><a href="<?the_permalink();?>"><?the_title();?></a></h2> <h2 class="mini-card-number-title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
</div> <!--//end minicard block --> </div> <!--//end minicard block -->
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<div class="numbers-anons">
<?//get_template_part( '/blocks/paginator');?> <p>Номера газеты выкладываются в общий доступ через месяц после выхода.</p>
<p>Заказать свежий номер можно на Wildberries по <u><a href="https://www.wildberries.ru/catalog/482667738/detail.aspx?targetUrl=EX" target="_blank">ссылке</a></u></p>
<?endif?> </div>
<div class="pagination-wrapper"> <div class="pagination-wrapper">
<nav class="navigation pagination" role="navigation" aria-label="Записи"> <nav class="navigation pagination" role="navigation" aria-label="Записи">
<div class="nav-links"> <div class="nav-links">

View File

@@ -46,7 +46,6 @@ $nn = 0;?>
<a href="<?the_permalink();?>"><img class="mini-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'full'); ?>" alt="<?the_title();?>"></a> <a href="<?the_permalink();?>"><img class="mini-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'full'); ?>" alt="<?the_title();?>"></a>
<?endif?> <?endif?>
<h2 class="mini-card-title"><a href="<?the_permalink();?>"><?the_title();?></a></h2> <h2 class="mini-card-title"><a href="<?the_permalink();?>"><?the_title();?></a></h2>
<div><a href="<?the_permalink();?>"><?the_excerpt();?></a></div>
<div class="mini-card-body"> <div class="mini-card-body">
<div class="news_date"><?the_time('j F Y, G:i');?></div> <div class="news_date"><?the_time('j F Y, G:i');?></div>
</div> </div>

View File

@@ -36,17 +36,11 @@
</a> </a>
</div> </div>
<?get_template_part( '/cats/cats-informer');?>
<div class="right-info"> <div class="right-info">
<!-- Yandex.RTB R-A-4145099-1 --> <!-- Yandex.RTB R-A-4145099-1 -->
<div id="yandex_rtb_R-A-4145099-1"></div>
<script>
window.yaContextCb.push(()=>{
Ya.Context.AdvManager.render({
"blockId": "R-A-4145099-1",
"renderTo": "yandex_rtb_R-A-4145099-1"
})
})
</script>
</div> </div>
@@ -62,21 +56,17 @@ window.yaContextCb.push(()=>{
<div id="right"> <div id="right">
<?php //include get_template_directory().'/blocks/archive.php';?> <?php //include get_template_directory().'/blocks/archive.php';?>
<?php //include VIJ_CACHE.'archive.html'?> <?php get_template_part('/blocks/archive-pets');?>
<?php get_template_part('partials/formsubscript'); ?> <?php get_template_part('blocks/formsubscript'); ?>
<?if (LANG_VERSION == 'ru'):?> <?if (LANG_VERSION == 'ru'):?>
<?if (function_exists('ex_adv_get_banner')): <?if (function_exists('krutilka_placement')){
echo krutilka_placement( 'right-desktop-1', 'right-info' );
$adv_left_1 = ex_adv_get_banner( 2 ); }?>
if ($adv_left_1 !== ''):?>
<div class="right-info">
<?=$adv_left_1?>
</div>
<?endif?>
<?if (function_exists('ex_adv_get_banner')):?>
<?$adv_left_2 = ex_adv_get_banner( 4 ); <?$adv_left_2 = ex_adv_get_banner( 4 );
if ($adv_left_2 !== ''):?> if ($adv_left_2 !== ''):?>
@@ -149,14 +139,11 @@ window.yaContextCb.push(()=>{
<?if (LANG_VERSION == 'ru'):?> <?if (LANG_VERSION == 'ru'):?>
<?if (function_exists('ex_adv_get_banner')): <?if (function_exists('krutilka_placement')){
echo krutilka_placement( 'mobile-1', 'mobile-info' );
}?>
$left_mobail_1 = ex_adv_get_banner(6); <?if (function_exists('ex_adv_get_banner')):?>
if ($left_mobail_1 !== ''):?>
<div class="mobile-info">
<?=$left_mobail_1?>
</div>
<?endif?>
<?$left_mobail_2 = ex_adv_get_banner(7); <?$left_mobail_2 = ex_adv_get_banner(7);
if ($left_mobail_2 !== ''):?> if ($left_mobail_2 !== ''):?>
@@ -180,16 +167,7 @@ window.yaContextCb.push(()=>{
<?php include get_template_directory().'/blocks/mobile-subscript.php';?> <?php include get_template_directory().'/blocks/mobile-subscript.php';?>
<!-- Yandex.RTB R-A-4145099-4 -->
<script>
window.yaContextCb.push(()=>{
Ya.Context.AdvManager.render({
"blockId": "R-A-4145099-4",
"type": "floorAd",
"platform": "touch"
})
})
</script>
<footer id="footer"> <footer id="footer">

View File

@@ -23,6 +23,7 @@
<?php // get_template_part( '/blocks/citats'); <?php // get_template_part( '/blocks/citats');
get_template_part( '/blocks/pets'); get_template_part( '/blocks/pets');
get_template_part( '/cats/cats-informer');
//get_blocks_gen( 'citats' );?> //get_blocks_gen( 'citats' );?>
<?php //include VIJ_CACHE.'opinion.html';?> <?php //include VIJ_CACHE.'opinion.html';?>
<?php //get_template_part( '/blocks/citata', null, ['subclass' => '']);?> <?php //get_template_part( '/blocks/citata', null, ['subclass' => '']);?>
@@ -64,31 +65,23 @@ window.yaContextCb.push(()=>{
<?php include get_template_directory().'/blocks/archive.php';?> <?php include get_template_directory().'/blocks/archive.php';?>
<?php //include VIJ_CACHE.'archive.html'?> <?php //include VIJ_CACHE.'archive.html'?>
<?if (function_exists('ex_adv_get_banner')): <?if (function_exists('krutilka_placement')){
echo krutilka_placement( 'right-desktop-1', 'right-info' );
}?>
$adv_left = ex_adv_get_banner( 2 );
if ($adv_left !== ''):?>
<div class="right-info">
<?=$adv_left?>
</div>
<?endif?>
<?endif?>
<?php get_template_part('partials/formsubscript'); ?> <?php get_template_part('partials/formsubscript'); ?>
<?if (function_exists('krutilka_placement')){
echo krutilka_placement( 'right-desktop-2', 'right-info' );
}?>
<?if (LANG_VERSION == 'ru'):?> <?if (LANG_VERSION == 'ru'):?>
<?if (function_exists('ex_adv_get_banner')): <?if (function_exists('ex_adv_get_banner')):?>
$adv_left_2 = ex_adv_get_banner( 4 );
if ($adv_left_2 !== ''):?>
<div class="right-info">
<?=$adv_left_2?>
</div>
<?endif?>
<?$adv_left_3 = ex_adv_get_banner( 5 ); <?$adv_left_3 = ex_adv_get_banner( 5 );
if ($adv_left_3 !== ''):?> if ($adv_left_3 !== ''):?>
@@ -113,6 +106,10 @@ window.yaContextCb.push(()=>{
get_blocks_gen( 'zakons' ); get_blocks_gen( 'zakons' );
}?> }?>
<?if (function_exists('krutilka_placement')){
echo krutilka_placement( 'right-desktop-3', 'right-info' );
}?>
<?if (LANG_VERSION == 'en'):?> <?if (LANG_VERSION == 'en'):?>
<?get_template_part( '/blocks/enmosts', null, ['subclass' => '']);?> <?get_template_part( '/blocks/enmosts', null, ['subclass' => '']);?>
<?get_template_part( '/blocks/enmosts', null, ['subclass' => 'mob-lite']);?> <?get_template_part( '/blocks/enmosts', null, ['subclass' => 'mob-lite']);?>
@@ -138,19 +135,12 @@ window.yaContextCb.push(()=>{
<?if (LANG_VERSION == 'ru'):?> <?if (LANG_VERSION == 'ru'):?>
<?if (function_exists('ex_adv_get_banner')): <?if (function_exists('krutilka_placement')){
echo krutilka_placement( 'mobile-1', 'mobile-info' );
$right_mobail_1 = ex_adv_get_banner( 9 ); }?>
if ($right_mobail_1 !== ''):?>
<div class="mobile-info">
<?=$right_mobail_1?>
</div>
<?endif?>
<?endif?>
<?//get_template_part( '/blocks/mosts', null, ['subclass' => 'mob-lite']);?> <?//get_template_part( '/blocks/mosts', null, ['subclass' => 'mob-lite']);?>
<?php get_template_part( '/cats/cats-informer', null, ['subclass' => 'mob-lite']);?>
<?include VIJ_CACHE.'top_mob.html'?> <?include VIJ_CACHE.'top_mob.html'?>
<?get_template_part( '/blocks/enmosts', null, ['subclass' => 'mob-lite']);?> <?get_template_part( '/blocks/enmosts', null, ['subclass' => 'mob-lite']);?>
@@ -159,32 +149,14 @@ window.yaContextCb.push(()=>{
<?php include get_template_directory().'/blocks/mobile-gazeta.php';?> <?php include get_template_directory().'/blocks/mobile-gazeta.php';?>
<?if (LANG_VERSION == 'ru'):?> <?if (LANG_VERSION == 'ru'):?>
<?if (function_exists('ex_adv_get_banner')): <?if (function_exists('krutilka_placement')){
echo krutilka_placement( 'mobile-1', 'mobile-info' );
$left_mobail_1 = ex_adv_get_banner(6); echo krutilka_placement( 'mobile-2', 'mobile-info' );
if ($left_mobail_1 !== ''):?> echo krutilka_placement( 'mobile-3', 'mobile-info' );
<div class="mobile-info"> }?>
<?=$left_mobail_1?>
</div>
<?endif?>
<?$left_mobail_2 = ex_adv_get_banner(7);
if ($left_mobail_2 !== ''):?>
<div class="mobile-info">
<?=$left_mobail_2?>
</div>
<?endif?>
<?$left_mobail_3 = ex_adv_get_banner(8);
if ($left_mobail_3 !== ''):?>
<div class="mobile-info">
<?=$left_mobail_3?>
</div>
<?endif?>
<?endif?>
@@ -192,17 +164,6 @@ window.yaContextCb.push(()=>{
<?php include get_template_directory().'/blocks/mobile-subscript.php';?> <?php include get_template_directory().'/blocks/mobile-subscript.php';?>
<!-- Yandex.RTB R-A-4145099-4 -->
<script>
window.yaContextCb.push(()=>{
Ya.Context.AdvManager.render({
"blockId": "R-A-4145099-4",
"type": "floorAd",
"platform": "touch"
})
})
</script>
<footer id="footer"> <footer id="footer">

View File

@@ -108,10 +108,24 @@ require get_template_directory().'/src/calendar.php';
require get_template_directory().'/src/perevod.php'; require get_template_directory().'/src/perevod.php';
require get_template_directory().'/lang.php'; // функции перевода require get_template_directory().'/lang.php'; // функции перевода
require get_template_directory().'/src/number-pdf.php'; // загрузка PDF номера require get_template_directory().'/src/number-pdf.php'; // загрузка PDF номера
require get_template_directory().'/src/journal_issue.php'; // загрузка журнала Питомцы
require get_template_directory().'/src/dznews.php'; // добавить в Дзен Новости
//require get_template_directory().'/blocks/card_post_id.php'; //require get_template_directory().'/blocks/card_post_id.php';
add_post_type_support('post', 'page-attributes'); add_post_type_support('post', 'page-attributes');
//для котов
require get_template_directory().'/cats/cats-type.php'; // кошки
require get_template_directory().'/cats/cats-redirect.php'; // кошки
function add_google_fonts() {
wp_enqueue_style('google-fonts', 'https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Open+Sans:ital,wght@0,300..800;1,300..800&family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap&display=swap');
}
add_action('wp_enqueue_scripts', 'add_google_fonts');
//require ABSPATH.'vendor/masterforweb/db_lite/db_lite.php'; //require ABSPATH.'vendor/masterforweb/db_lite/db_lite.php';
//[_site_admin_email] //[_site_admin_email]

View File

@@ -1,46 +1,166 @@
<?php <?php
function number_info($title, $post_id = 0) { function number_info($title, $post_id = 0) {
$res = []; $res = [];
$items = explode(' ', $title); $items = explode(' ', $title);
$res['year'] = $items[4]; // Инициализируем переменные
$res['number'] = $number; $res['year'] = isset($items[4]) ? $items[4] : '';
$res['number'] = '';
$res['guid'] = '';
// Проверяем PDF в метаполях
$pdf_url = get_post_meta($post_id, '_pdf_file', true); $pdf_url = get_post_meta($post_id, '_pdf_file', true);
if ($pdf_url) { if ($pdf_url) {
$res['guid'] = esc_url($pdf_url); $res['guid'] = esc_url($pdf_url);
return $res; return $res;
} }
$number = substr($items[2], 1, strlen($items[2]) - 2); // Извлекаем номер
$name = 'vizh_'.$number.'_'.ru2enmonths($items[3]).'_'.$items[4]; if (isset($items[2])) {
$res['number'] = substr($items[2], 1, strlen($items[2]) - 2);
//echo '<p>'.$name.'</p>';
$findpdf = db_get("SELECT * FROM `wp_posts` WHERE `post_name` = '$name' ORDER BY `post_modified` DESC LIMIT 1");
//echo "SELECT * FROM `wp_posts` WHERE `post_name` = '$name' ORDER BY `post_modified` DESC LIMIT 1";
if (isset($findpdf['guid'])){
$res['guid'] = $findpdf['guid'];
} }
// Формируем имя для поиска
$month = isset($items[3]) ? ru2enmonths($items[3]) : '';
$year = isset($items[4]) ? $items[4] : '';
if ($res['number'] && $month && $year) {
$name = 'vizh_' . $res['number'] . '_' . $month . '_' . $year;
// Используем стандартные методы WordPress для поиска поста
$findpdf = get_posts([
'name' => $name,
'post_type' => 'attachment',
'post_status' => 'inherit',
'post_mime_type' => 'application/pdf',
'posts_per_page' => 1,
'orderby' => 'post_modified',
'order' => 'DESC'
]);
if (!empty($findpdf)) {
$post = $findpdf[0];
$res['guid'] = get_the_guid($post->ID);
// Альтернативно можно получить URL через permalink
// $res['guid'] = get_permalink($post->ID);
}
}
return $res; return $res;
} }
// Альтернативная версия с использованием WP_Query
function number_info_alt($title, $post_id = 0) {
$res = [];
$items = explode(' ', $title);
$res['year'] = isset($items[4]) ? $items[4] : '';
$res['number'] = '';
$res['guid'] = '';
// Проверяем PDF в метаполях
$pdf_url = get_post_meta($post_id, '_pdf_file', true);
if ($pdf_url) {
$res['guid'] = esc_url($pdf_url);
return $res;
}
// Извлекаем номер
if (isset($items[2])) {
$res['number'] = substr($items[2], 1, strlen($items[2]) - 2);
}
// Формируем имя для поиска
$month = isset($items[3]) ? ru2enmonths($items[3]) : '';
$year = isset($items[4]) ? $items[4] : '';
if ($res['number'] && $month && $year) {
$name = 'vizh_' . $res['number'] . '_' . $month . '_' . $year;
// Используем WP_Query для более гибкого поиска
$query = new WP_Query([
'name' => $name,
'post_type' => 'any',
'post_status' => 'publish',
'posts_per_page' => 1,
'orderby' => 'modified',
'order' => 'DESC'
]);
if ($query->have_posts()) {
$query->the_post();
$res['guid'] = get_the_guid();
wp_reset_postdata();
}
}
return $res;
}
function ru2enmonths($str) { function ru2enmonths($str) {
$ruMonths = [
$ruMonths = ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь']; 'январь', 'февраль', 'март', 'апрель', 'май', 'июнь',
$enMonths = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december']; 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'
];
$enMonths = [
'january', 'february', 'march', 'april', 'may', 'june',
'july', 'august', 'september', 'october', 'november', 'december'
];
$enDate = str_ireplace($ruMonths, $enMonths, $str); $enDate = str_ireplace($ruMonths, $enMonths, $str);
return $enDate; return $enDate;
} }
// Еще более безопасная версия с проверкой slug
function number_info_safe($title, $post_id = 0) {
$res = [
'year' => '',
'number' => '',
'guid' => ''
];
$items = explode(' ', $title);
// Проверяем PDF в метаполях
$pdf_url = get_post_meta($post_id, '_pdf_file', true);
if ($pdf_url) {
$res['guid'] = esc_url($pdf_url);
return $res;
}
// Безопасное извлечение данных
if (count($items) >= 5) {
$res['year'] = sanitize_text_field($items[4]);
if (isset($items[2])) {
$res['number'] = substr($items[2], 1, strlen($items[2]) - 2);
}
$month = ru2enmonths($items[3]);
$name = 'vizh_' . $res['number'] . '_' . $month . '_' . $res['year'];
// Ищем пост по slug
$args = [
'name' => $name,
'post_type' => 'any',
'post_status' => 'publish',
'posts_per_page' => 1,
'orderby' => 'modified',
'order' => 'DESC'
];
$posts = get_posts($args);
if (!empty($posts)) {
$post = $posts[0];
$res['guid'] = get_permalink($post->ID); // Лучше использовать permalink чем guid
}
}
return $res;
}

View File

@@ -20,25 +20,17 @@ function create_rss_yandex(){
$posts = get_posts( array( $posts = get_posts( array(
'numberposts' => 20, 'numberposts' => 20,
'category' => 2,
'orderby' => 'date', 'orderby' => 'date',
'order' => 'DESC', 'order' => 'DESC',
'include' => array(), 'include' => array(),
'exclude' => array(), 'exclude' => array(),
'meta_key' => '',
'meta_value' =>'',
'post_type' => 'post', 'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса 'suppress_filters' => true,
'meta_query' => array( 'meta_query' => array(
'relation' => 'OR',
array( array(
'key' => '_erid_token', 'key' => '_send_to_zen_news',
'value' => '', 'value' => '1',
'compare' => '=' 'compare' => '='
),
array(
'key' => '_erid_token',
'compare' => 'NOT EXISTS'
) )
) )
)); ));

View File

@@ -52,33 +52,43 @@ get_header();?>
<?endif?> <?endif?>
</div> </div>
<?php <?php
// Обработка ошибки в функции get_posts() с тегом
try {
?> $posts = get_posts([
<?$posts = get_posts([
'tag' => 'номер'.$curr_number['number'], 'tag' => 'номер'.$curr_number['number'],
'post_type' => 'post', 'post_type' => 'post',
'numberposts' => -1 'numberposts' => -1
]); ]);
} catch (Exception $e) {
// Логируем ошибку и используем альтернативный подход
error_log('Error in get_posts with tag: ' . $e->getMessage());
// Альтернативный способ получения постов по тегу
$tag = get_term_by('name', 'номер'.$curr_number['number'], 'post_tag');
if ($tag) {
$posts = get_posts([
'tag_id' => $tag->term_id,
'post_type' => 'post',
'numberposts' => -1
]);
} else {
$posts = [];
}
}
$pitems = []; $pitems = [];
$endpolosa = 1; $endpolosa = 1;
if (!empty($posts)) { if (!empty($posts)) {
foreach ($posts as $post) { foreach ($posts as $post) {
$posttags = get_the_tags($post->ID); $posttags = get_the_tags($post->ID);
if ($posttags) {
foreach ($posttags as $tag) { foreach ($posttags as $tag) {
$pfind = strpos($tag->name, 'полоса'); $pfind = strpos($tag->name, 'полоса');
if ($pfind !== false) { if ($pfind !== false) {
$number = (int)substr($tag->name, 0, $pfind); $number = (int)substr($tag->name, 0, $pfind);
if ($number > $endpolosa) { if ($number > $endpolosa) {
@@ -87,50 +97,67 @@ get_header();?>
$pitems[$number][] = $post; $pitems[$number][] = $post;
} }
} }
} }
}
?> ?>
<?for ($i = 1; $i <= $endpolosa; $i++) {?> <?php for ($i = 1; $i <= $endpolosa; $i++) { ?>
<?if (isset($pitems[$i])):?> <?php if (isset($pitems[$i])): ?>
<!--<h2 class="part_title">Полоса <?=$i?></h2>--> <!--<h2 class="part_title">Полоса <?php echo $i; ?></h2>-->
<?foreach($pitems[$i] as $item):?> <?php foreach($pitems[$i] as $item): ?>
<?$category = get_the_category($item->ID); <?php
$category = get_the_category($item->ID);
$category_id = $category[0]->term_id; $category_id = $category[0]->term_id;
$category_link = get_category_link($category_id);?> $category_link = get_category_link($category_id);
?>
<div class="main-card"> <div class="main-card">
<?if ( has_post_thumbnail($item->ID) ) :?> <?php if (has_post_thumbnail($item->ID)) : ?>
<div class="polosa-img"> <div class="polosa-img">
<a href="<?the_permalink($item->ID);?>"><img src="<?php echo get_the_post_thumbnail_url($item->ID, 'large'); ?>" alt="<?=$item->title;?>"></a> <a href="<?php the_permalink($item->ID); ?>">
<img src="<?php echo get_the_post_thumbnail_url($item->ID, 'large'); ?>" alt="<?php echo esc_attr($item->post_title); ?>">
</a>
</div>
<?php endif; ?>
<br>
<div class="main-card-title">
<p>
<a href="<?php the_permalink($item->ID); ?>">
<?php echo get_the_title($item->ID); ?>
</a>
</p>
</div> </div>
<?endif?><br>
<div class="main-card-title"><p><a href="<?the_permalink($item->ID);?>"><?=get_the_title($item->ID);?></a></p></div>
<div class="main-card-body"> <div class="main-card-body">
<div><a href="<?the_permalink($item->ID);?>"><?=$item->post_excerpt?></a></div><br> <div>
<div class="news_date"><a href="<?=$category_link?>"><?=$category['0']->name?></a></div> <a href="<?php the_permalink($item->ID); ?>">
<?php echo $item->post_excerpt; ?>
</a>
</div>
<br>
<div class="news_date">
<a href="<?php echo $category_link; ?>">
<?php echo $category[0]->name; ?>
</a>
</div> </div>
</div> </div>
<?endforeach?> </div>
<?endif?> <?php endforeach; ?>
<?} <?php endif; ?>
<?php }
} ?> } ?>
<?php <?php
$numbers_year = date('Y'); $numbers_year = date('Y');
include get_template_directory().'/blocks/arh_more.php'; include get_template_directory().'/blocks/arh_more.php';
?> ?>
<div class="publ-to-main"> <div class="publ-to-main">
<button class="more_button" onclick="location.href='<?=get_site_url()?>/category/arkhiv'" type="button"> <button class="more_button" onclick="location.href='<?php echo get_site_url(); ?>/category/arkhiv'" type="button">
Архив номеров</button> Архив номеров
</button>
</div> </div>
</div> </div>

View File

@@ -47,6 +47,7 @@ if ( $pets_cat ){
if ( $pets_cat ):?> if ( $pets_cat ):?>
<?echo "<!-- pets: $category_name-->"?> <?echo "<!-- pets: $category_name-->"?>
<ul id="nav_content"> <ul id="nav_content">
<li><a href="<?=get_site_url()?>/category/pets">Питомцы</li> <li><a href="<?=get_site_url()?>/category/pets">Питомцы</li>
@@ -55,6 +56,22 @@ if ( $pets_cat ){
<li>-<li> <li>-<li>
<li><?=mb_substr(get_the_title(), 0, 50);?>...</li> <li><?=mb_substr(get_the_title(), 0, 50);?>...</li>
</ul> </ul>
<?$categories = get_the_category();
if (count($categories) > 1 ){
if (!empty($categories)){
$category_links = '';
foreach ($categories as $cat) {
if ($cat->name == 'Новости' or $cat->name == 'События'){
continue;
}
if ($category_links !== ''){
$category_links .= ', ';
}
$category_item = get_category_link($cat->term_id);
$category_links .= '<a href="' . $category_item . '">' . $cat->name . '</a>';
}
}
}?>
<?else: <?else:
$category = get_the_category(); $category = get_the_category();
$category_id = $category[0]->term_id; $category_id = $category[0]->term_id;
@@ -73,7 +90,12 @@ if ( $pets_cat ){
<div class="post_info"> <div class="post_info">
<div class="post_info_sub"> <div class="post_info_sub">
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category_name;?></a></span>, <nobr><?php the_time('j F Y, G:i');?></nobr> <?if (isset( $category_links )):?>
<span class="post_link_category"><?php echo $category_links; ?></span>
<?else:?>
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category_name;?></a></span>
<?endif?>
, <nobr><?php the_time('j F Y, G:i');?></nobr>
</div> </div>
<div class="post_info_sub post_info_social"> <div class="post_info_sub post_info_social">
<?php include get_template_directory().'/blocks/social-share.php';?> <?php include get_template_directory().'/blocks/social-share.php';?>

View File

@@ -33,8 +33,8 @@ add_action( 'wp_enqueue_scripts', function () {
$style_ver = filemtime(get_template_directory() . $fstyle); $style_ver = filemtime(get_template_directory() . $fstyle);
$script_ver = filemtime(get_template_directory() . $fscript); $script_ver = filemtime(get_template_directory() . $fscript);
wp_enqueue_style('vij-style', get_template_directory_uri() . $fstyle, array(), $style_ver.'17'); wp_enqueue_style('vij-style', get_template_directory_uri() . $fstyle, array(), $style_ver);
wp_enqueue_script('vij-script', get_template_directory_uri() . $fscript, array(), $script_ver.'10', 5); wp_enqueue_script('vij-script', get_template_directory_uri() . $fscript, array(), $script_ver);
} }
}); });