correct data
This commit is contained in:
@@ -42,9 +42,7 @@ if ( $random_posts ) {
|
||||
<div class="pets-widget-maintitle"><a href="/pets">Питомцы</a></div>
|
||||
<a href="<?php the_permalink(); ?>">
|
||||
<?php if ( has_post_thumbnail() ) : ?>
|
||||
<div>
|
||||
<?php the_post_thumbnail('medium'); ?>
|
||||
</div>
|
||||
<?php the_post_thumbnail('medium'); ?>
|
||||
<?php endif; ?>
|
||||
<h3 class="pets-widget-title"><?php the_title(); ?></h3>
|
||||
</a>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
<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://www.youtube.com/c/ВетеринарияиЖизнь" 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://rutube.ru/channel/42943284/" target="_blank"><span class="socs soc-rutube"></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="soc_btn soc_fb"></div>
|
||||
|
||||
103
category-3.php
103
category-3.php
@@ -23,95 +23,84 @@ get_header();?>
|
||||
<h1 class="my-4"><?single_cat_title()?></h1>
|
||||
|
||||
<div class="numbers-anons">
|
||||
<p>Федеральное отраслевое издание «Ветеринария и жизнь» выходит с 2017 года и является крупнейшим периодическим печатным изданием в сфере сельского хозяйства и ветеринарии. К скачиванию доступен архив за все годы существования издания.<br><br>
|
||||
Номера газеты выкладываются в общий доступ через месяц после выхода.<br><br>
|
||||
Заказать свежий номер можно на Wildberries по <u><a href="https://www.wildberries.ru/catalog/482667738/detail.aspx?targetUrl=EX" target="_blank">ссылке</a></u></p>
|
||||
<p>Федеральное отраслевое издание «Ветеринария и жизнь» выходит с 2017 года и является крупнейшим периодическим печатным изданием в сфере сельского хозяйства и ветеринарии. К скачиванию доступен архив за все годы существования издания.</p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
$page = get_query_var('paged');
|
||||
$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
|
||||
|
||||
'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 {
|
||||
} else {
|
||||
$numbers_year = $curryear - ($page - 1);
|
||||
}
|
||||
|
||||
|
||||
$curr_params = $year_params;
|
||||
$curr_params['year'] = $numbers_year;
|
||||
|
||||
$posts = get_posts($curr_params);
|
||||
|
||||
if (count($posts) == 0){
|
||||
|
||||
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"><?=$numbers_year?></div>
|
||||
|
||||
if (count($posts) > 0): ?>
|
||||
<div class="numbers-year-title"><?php echo $numbers_year; ?></div>
|
||||
<div class="mini-card-block">
|
||||
|
||||
<?foreach($posts as $post):
|
||||
setup_postdata( $post );
|
||||
?>
|
||||
|
||||
|
||||
<?$curr_number = number_info(get_the_title());?>
|
||||
<?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">
|
||||
<?if ( has_post_thumbnail() ) :?>
|
||||
<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>
|
||||
<?if( has_tag( 'видео' ) ):?>
|
||||
<span class="play-card"></span>
|
||||
<?endif?>
|
||||
</div>
|
||||
<?endif?>
|
||||
<h2 class="mini-card-number-title"><a href="<?the_permalink();?>"><?the_title();?></a></h2>
|
||||
<?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 -->
|
||||
|
||||
|
||||
|
||||
<?//get_template_part( '/blocks/paginator');?>
|
||||
|
||||
<?endif?>
|
||||
<?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">
|
||||
|
||||
@@ -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>
|
||||
<?endif?>
|
||||
<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="news_date"><?the_time('j F Y, G:i');?></div>
|
||||
</div>
|
||||
|
||||
@@ -36,17 +36,11 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?get_template_part( '/cats/cats-informer');?>
|
||||
|
||||
<div class="right-info">
|
||||
<!-- 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>
|
||||
|
||||
|
||||
@@ -62,22 +56,18 @@ window.yaContextCb.push(()=>{
|
||||
<div id="right">
|
||||
|
||||
<?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 (function_exists('ex_adv_get_banner')):
|
||||
|
||||
$adv_left_1 = ex_adv_get_banner( 2 );
|
||||
if ($adv_left_1 !== ''):?>
|
||||
<div class="right-info">
|
||||
<?=$adv_left_1?>
|
||||
</div>
|
||||
<?endif?>
|
||||
|
||||
|
||||
<?if (function_exists('krutilka_placement')){
|
||||
echo krutilka_placement( 'right-desktop-1', 'right-info' );
|
||||
}?>
|
||||
|
||||
<?if (function_exists('ex_adv_get_banner')):?>
|
||||
|
||||
<?$adv_left_2 = ex_adv_get_banner( 4 );
|
||||
if ($adv_left_2 !== ''):?>
|
||||
<div class="right-info">
|
||||
@@ -149,15 +139,12 @@ window.yaContextCb.push(()=>{
|
||||
|
||||
<?if (LANG_VERSION == 'ru'):?>
|
||||
|
||||
<?if (function_exists('ex_adv_get_banner')):
|
||||
|
||||
$left_mobail_1 = ex_adv_get_banner(6);
|
||||
if ($left_mobail_1 !== ''):?>
|
||||
<div class="mobile-info">
|
||||
<?=$left_mobail_1?>
|
||||
</div>
|
||||
<?endif?>
|
||||
<?if (function_exists('krutilka_placement')){
|
||||
echo krutilka_placement( 'mobile-1', 'mobile-info' );
|
||||
}?>
|
||||
|
||||
<?if (function_exists('ex_adv_get_banner')):?>
|
||||
|
||||
<?$left_mobail_2 = ex_adv_get_banner(7);
|
||||
if ($left_mobail_2 !== ''):?>
|
||||
<div class="mobile-info">
|
||||
@@ -180,16 +167,7 @@ window.yaContextCb.push(()=>{
|
||||
|
||||
<?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">
|
||||
|
||||
91
footer.php
91
footer.php
@@ -23,6 +23,7 @@
|
||||
|
||||
<?php // get_template_part( '/blocks/citats');
|
||||
get_template_part( '/blocks/pets');
|
||||
get_template_part( '/cats/cats-informer');
|
||||
//get_blocks_gen( 'citats' );?>
|
||||
<?php //include VIJ_CACHE.'opinion.html';?>
|
||||
<?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 VIJ_CACHE.'archive.html'?>
|
||||
|
||||
<?if (function_exists('ex_adv_get_banner')):
|
||||
|
||||
$adv_left = ex_adv_get_banner( 2 );
|
||||
if ($adv_left !== ''):?>
|
||||
<div class="right-info">
|
||||
<?=$adv_left?>
|
||||
</div>
|
||||
<?endif?>
|
||||
|
||||
<?endif?>
|
||||
<?if (function_exists('krutilka_placement')){
|
||||
echo krutilka_placement( 'right-desktop-1', 'right-info' );
|
||||
}?>
|
||||
|
||||
|
||||
|
||||
<?php get_template_part('partials/formsubscript'); ?>
|
||||
|
||||
<?if (function_exists('krutilka_placement')){
|
||||
echo krutilka_placement( 'right-desktop-2', 'right-info' );
|
||||
}?>
|
||||
|
||||
|
||||
<?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 );
|
||||
if ($adv_left_3 !== ''):?>
|
||||
@@ -102,8 +95,8 @@ window.yaContextCb.push(()=>{
|
||||
|
||||
|
||||
|
||||
<?endif?>
|
||||
|
||||
<?endif?>
|
||||
|
||||
|
||||
<?if (LANG_VERSION == 'en'){
|
||||
get_template_part( '/blocks/regulation');
|
||||
@@ -112,6 +105,10 @@ window.yaContextCb.push(()=>{
|
||||
// get_template_part( '/blocks/zakons');
|
||||
get_blocks_gen( 'zakons' );
|
||||
}?>
|
||||
|
||||
<?if (function_exists('krutilka_placement')){
|
||||
echo krutilka_placement( 'right-desktop-3', 'right-info' );
|
||||
}?>
|
||||
|
||||
<?if (LANG_VERSION == 'en'):?>
|
||||
<?get_template_part( '/blocks/enmosts', null, ['subclass' => '']);?>
|
||||
@@ -138,19 +135,12 @@ window.yaContextCb.push(()=>{
|
||||
|
||||
<?if (LANG_VERSION == 'ru'):?>
|
||||
|
||||
<?if (function_exists('ex_adv_get_banner')):
|
||||
|
||||
$right_mobail_1 = ex_adv_get_banner( 9 );
|
||||
|
||||
if ($right_mobail_1 !== ''):?>
|
||||
<div class="mobile-info">
|
||||
<?=$right_mobail_1?>
|
||||
</div>
|
||||
<?endif?>
|
||||
|
||||
<?endif?>
|
||||
<?if (function_exists('krutilka_placement')){
|
||||
echo krutilka_placement( 'mobile-1', 'mobile-info' );
|
||||
}?>
|
||||
|
||||
<?//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'?>
|
||||
<?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';?>
|
||||
|
||||
|
||||
|
||||
<?if (LANG_VERSION == 'ru'):?>
|
||||
|
||||
<?if (function_exists('ex_adv_get_banner')):
|
||||
|
||||
$left_mobail_1 = ex_adv_get_banner(6);
|
||||
if ($left_mobail_1 !== ''):?>
|
||||
<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?>
|
||||
<?if (function_exists('krutilka_placement')){
|
||||
echo krutilka_placement( 'mobile-1', 'mobile-info' );
|
||||
echo krutilka_placement( 'mobile-2', 'mobile-info' );
|
||||
echo krutilka_placement( 'mobile-3', 'mobile-info' );
|
||||
}?>
|
||||
|
||||
|
||||
|
||||
@@ -192,17 +164,6 @@ window.yaContextCb.push(()=>{
|
||||
|
||||
<?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">
|
||||
|
||||
|
||||
@@ -108,10 +108,24 @@ require get_template_directory().'/src/calendar.php';
|
||||
require get_template_directory().'/src/perevod.php';
|
||||
require get_template_directory().'/lang.php'; // функции перевода
|
||||
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';
|
||||
|
||||
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';
|
||||
|
||||
//[_site_admin_email]
|
||||
|
||||
@@ -1,46 +1,166 @@
|
||||
<?php
|
||||
|
||||
function number_info($title, $post_id = 0){
|
||||
|
||||
function number_info($title, $post_id = 0) {
|
||||
$res = [];
|
||||
|
||||
$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);
|
||||
if ($pdf_url) {
|
||||
$res['guid'] = esc_url($pdf_url);
|
||||
return $res;
|
||||
}
|
||||
|
||||
$number = substr($items[2], 1, strlen($items[2]) - 2);
|
||||
$name = 'vizh_'.$number.'_'.ru2enmonths($items[3]).'_'.$items[4];
|
||||
|
||||
//echo '<p>'.$name.'</p>';
|
||||
// Извлекаем номер
|
||||
if (isset($items[2])) {
|
||||
$res['number'] = substr($items[2], 1, strlen($items[2]) - 2);
|
||||
}
|
||||
|
||||
$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";
|
||||
// Формируем имя для поиска
|
||||
$month = isset($items[3]) ? ru2enmonths($items[3]) : '';
|
||||
$year = isset($items[4]) ? $items[4] : '';
|
||||
|
||||
if ($res['number'] && $month && $year) {
|
||||
$name = 'vizh_' . $res['number'] . '_' . $month . '_' . $year;
|
||||
|
||||
if (isset($findpdf['guid'])){
|
||||
$res['guid'] = $findpdf['guid'];
|
||||
}
|
||||
|
||||
// Используем стандартные методы 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'
|
||||
]);
|
||||
|
||||
return $res;
|
||||
if (!empty($findpdf)) {
|
||||
$post = $findpdf[0];
|
||||
$res['guid'] = get_the_guid($post->ID);
|
||||
|
||||
// Альтернативно можно получить URL через permalink
|
||||
// $res['guid'] = get_permalink($post->ID);
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Альтернативная версия с использованием WP_Query
|
||||
function number_info_alt($title, $post_id = 0) {
|
||||
$res = [];
|
||||
|
||||
function ru2enmonths($str){
|
||||
$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] : '';
|
||||
|
||||
$ruMonths = ['январь', 'февраль', 'март', 'апрель', 'май', 'июнь', 'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'];
|
||||
$enMonths = ['january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december'];
|
||||
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) {
|
||||
$ruMonths = [
|
||||
'январь', 'февраль', 'март', 'апрель', 'май', 'июнь',
|
||||
'июль', 'август', 'сентябрь', 'октябрь', 'ноябрь', 'декабрь'
|
||||
];
|
||||
$enMonths = [
|
||||
'january', 'february', 'march', 'april', 'may', 'june',
|
||||
'july', 'august', 'september', 'october', 'november', 'december'
|
||||
];
|
||||
|
||||
$enDate = str_ireplace($ruMonths, $enMonths, $str);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -19,29 +19,21 @@ exit;
|
||||
function create_rss_yandex(){
|
||||
|
||||
$posts = get_posts( array(
|
||||
'numberposts' => 20,
|
||||
'category' => 2,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'include' => array(),
|
||||
'exclude' => array(),
|
||||
'meta_key' => '',
|
||||
'meta_value' =>'',
|
||||
'post_type' => 'post',
|
||||
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => '_erid_token',
|
||||
'value' => '',
|
||||
'compare' => '='
|
||||
),
|
||||
array(
|
||||
'key' => '_erid_token',
|
||||
'compare' => 'NOT EXISTS'
|
||||
)
|
||||
'numberposts' => 20,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'include' => array(),
|
||||
'exclude' => array(),
|
||||
'post_type' => 'post',
|
||||
'suppress_filters' => true,
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => '_send_to_zen_news',
|
||||
'value' => '1',
|
||||
'compare' => '='
|
||||
)
|
||||
));
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// Яндекс Новости
|
||||
|
||||
159
single-3.php
159
single-3.php
@@ -50,85 +50,112 @@ get_header();?>
|
||||
<?endif?>
|
||||
</div>
|
||||
<?endif?>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
</div>
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<?$posts = get_posts([
|
||||
|
||||
'tag' => 'номер'.$curr_number['number'],
|
||||
'post_type' => 'post',
|
||||
<?php
|
||||
// Обработка ошибки в функции get_posts() с тегом
|
||||
try {
|
||||
$posts = get_posts([
|
||||
'tag' => 'номер'.$curr_number['number'],
|
||||
'post_type' => 'post',
|
||||
'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 = [];
|
||||
$endpolosa = 1;
|
||||
$pitems = [];
|
||||
$endpolosa = 1;
|
||||
|
||||
if ( !empty($posts) ) {
|
||||
|
||||
foreach ($posts as $post){
|
||||
|
||||
$posttags = get_the_tags($post->ID);
|
||||
|
||||
foreach ($posttags as $tag){
|
||||
$pfind = strpos($tag->name, 'полоса');
|
||||
if (!empty($posts)) {
|
||||
foreach ($posts as $post) {
|
||||
$posttags = get_the_tags($post->ID);
|
||||
|
||||
if ($posttags) {
|
||||
foreach ($posttags as $tag) {
|
||||
$pfind = strpos($tag->name, 'полоса');
|
||||
|
||||
if ($pfind !== false) {
|
||||
|
||||
$number = (int)substr($tag->name, 0, $pfind);
|
||||
|
||||
if ($number > $endpolosa ){
|
||||
$endpolosa = $number;
|
||||
}
|
||||
$pitems[$number][] = $post;
|
||||
if ($pfind !== false) {
|
||||
$number = (int)substr($tag->name, 0, $pfind);
|
||||
|
||||
if ($number > $endpolosa) {
|
||||
$endpolosa = $number;
|
||||
}
|
||||
$pitems[$number][] = $post;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?for ($i = 1; $i <= $endpolosa; $i++) {?>
|
||||
<?if (isset($pitems[$i])):?>
|
||||
<!--<h2 class="part_title">Полоса <?=$i?></h2>-->
|
||||
<?foreach($pitems[$i] as $item):?>
|
||||
<?$category = get_the_category($item->ID);
|
||||
$category_id = $category[0]->term_id;
|
||||
$category_link = get_category_link($category_id);?>
|
||||
|
||||
<div class="main-card">
|
||||
<?if ( has_post_thumbnail($item->ID) ) :?>
|
||||
<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>
|
||||
</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><a href="<?the_permalink($item->ID);?>"><?=$item->post_excerpt?></a></div><br>
|
||||
<div class="news_date"><a href="<?=$category_link?>"><?=$category['0']->name?></a></div>
|
||||
<?php for ($i = 1; $i <= $endpolosa; $i++) { ?>
|
||||
<?php if (isset($pitems[$i])): ?>
|
||||
<!--<h2 class="part_title">Полоса <?php echo $i; ?></h2>-->
|
||||
<?php foreach($pitems[$i] as $item): ?>
|
||||
<?php
|
||||
$category = get_the_category($item->ID);
|
||||
$category_id = $category[0]->term_id;
|
||||
$category_link = get_category_link($category_id);
|
||||
?>
|
||||
|
||||
<div class="main-card">
|
||||
<?php if (has_post_thumbnail($item->ID)) : ?>
|
||||
<div class="polosa-img">
|
||||
<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>
|
||||
</div>
|
||||
<?endforeach?>
|
||||
<?endif?>
|
||||
<?}
|
||||
}?>
|
||||
<?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 class="main-card-body">
|
||||
<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>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php }
|
||||
} ?>
|
||||
|
||||
<?php
|
||||
$numbers_year = date('Y');
|
||||
include get_template_directory().'/blocks/arh_more.php';
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
$numbers_year = date('Y');
|
||||
include get_template_directory().'/blocks/arh_more.php';
|
||||
?>
|
||||
|
||||
<div class="publ-to-main">
|
||||
<button class="more_button" onclick="location.href='<?=get_site_url()?>/category/arkhiv'" type="button">
|
||||
Архив номеров</button>
|
||||
</div>
|
||||
|
||||
<div class="publ-to-main">
|
||||
<button class="more_button" onclick="location.href='<?php echo get_site_url(); ?>/category/arkhiv'" type="button">
|
||||
Архив номеров
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
24
single.php
24
single.php
@@ -47,6 +47,7 @@ if ( $pets_cat ){
|
||||
|
||||
|
||||
if ( $pets_cat ):?>
|
||||
|
||||
<?echo "<!-- pets: $category_name-->"?>
|
||||
<ul id="nav_content">
|
||||
<li><a href="<?=get_site_url()?>/category/pets">Питомцы</li>
|
||||
@@ -55,6 +56,22 @@ if ( $pets_cat ){
|
||||
<li>-<li>
|
||||
<li><?=mb_substr(get_the_title(), 0, 50);?>...</li>
|
||||
</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:
|
||||
$category = get_the_category();
|
||||
$category_id = $category[0]->term_id;
|
||||
@@ -73,7 +90,12 @@ if ( $pets_cat ){
|
||||
|
||||
<div class="post_info">
|
||||
<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 class="post_info_sub post_info_social">
|
||||
<?php include get_template_directory().'/blocks/social-share.php';?>
|
||||
|
||||
@@ -32,9 +32,9 @@ add_action( 'wp_enqueue_scripts', function () {
|
||||
// Production version
|
||||
$style_ver = filemtime(get_template_directory() . $fstyle);
|
||||
$script_ver = filemtime(get_template_directory() . $fscript);
|
||||
|
||||
wp_enqueue_style('vij-style', get_template_directory_uri() . $fstyle, array(), $style_ver.'17');
|
||||
wp_enqueue_script('vij-script', get_template_directory_uri() . $fscript, array(), $script_ver.'10', 5);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user