start special project FOREST
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
<?php get_header( 'forest' ); ?>
|
||||
|
||||
<div class="content-middle articles-wrapper">
|
||||
<?php get_template_part('partials/rubrics-mobile'); ?>
|
||||
|
||||
|
||||
<div class="section-title desktop">
|
||||
<?php if (is_category()) : ?>
|
||||
<?php if (is_category()) :
|
||||
$current_cat = get_queried_object();?>
|
||||
<?php if ( $current_cat->name == 'Защита леса — защита будущего' ):?>
|
||||
<h1 class="section-title__title">Международная научно-практическая конференция<br>«Защита леса — защита будущего»</h1>
|
||||
<?php else:?>
|
||||
<h1 class="section-title__title"><?= get_queried_object()->name ?></h1>
|
||||
<?php endif; ?>
|
||||
<?php endif;
|
||||
endif; ?>
|
||||
</div>
|
||||
<div class="articles-preview">
|
||||
<?php
|
||||
|
||||
@@ -17,6 +17,7 @@ import './styles/components/interview-item.css';
|
||||
import './styles/components/partner-item.css';
|
||||
import './styles/components/single-partner-item.css';
|
||||
import './styles/components/suggestion-item.css';
|
||||
import './styles/components/agro-informer.css';
|
||||
|
||||
import './scripts/calendar.js';
|
||||
import './scripts/menu-vertical.js';
|
||||
|
||||
37
frontend/src/styles/components/agro-informer.css
Normal file
37
frontend/src/styles/components/agro-informer.css
Normal file
@@ -0,0 +1,37 @@
|
||||
.agro-widget {
|
||||
margin-bottom: 8px;
|
||||
margin-top: 6px;
|
||||
max-width: 100%;
|
||||
background-color: white;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.agro-widget h3{
|
||||
line-height: 2rem;
|
||||
}
|
||||
|
||||
.agro-widget IMG{
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.agro-widget-maintitle{
|
||||
font-size: 1.8rem;
|
||||
font-weight: 700;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 18px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.agro-widget-maintitle a {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.agro-widget-title {
|
||||
font-size: 1.8rem;
|
||||
padding: 2.5rem 3.8rem;
|
||||
font-weight: 700;
|
||||
padding: 12px;
|
||||
}
|
||||
@@ -15,9 +15,10 @@
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/**
|
||||
.header__logo img {
|
||||
max-width: 100%;
|
||||
}
|
||||
}*/
|
||||
|
||||
.header__right {
|
||||
display: flex;
|
||||
|
||||
@@ -63,8 +63,8 @@ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
<div class="container">
|
||||
<div class="header__inner">
|
||||
<?php $site_logo = get_field('site_logo', 'option');?>
|
||||
<a href="<?php echo home_url(); ?>" class="logo header__logo">
|
||||
<img src="<?php echo esc_url($site_logo); ?>" width="158" alt="" />
|
||||
<a href="/forest" class="logo header__logo">
|
||||
<img src="https://agroexpert.press/wp-content/uploads/2025/05/agroexpert-forest.svg" width="340" alt="Защита леса - защита будущего - Агроэксперт" />
|
||||
</a>
|
||||
<nav class="nav header__nav">
|
||||
<?php get_template_part('partials/menu-forest'); ?>
|
||||
|
||||
@@ -19,3 +19,31 @@ add_filter('category_template', function($template) {
|
||||
|
||||
return $template;
|
||||
});
|
||||
|
||||
add_filter('single_template', function($template) {
|
||||
global $post;
|
||||
|
||||
// Список целевых родительских рубрик (как в category_template)
|
||||
$target_parent_slugs = ['forest', 'rfo'];
|
||||
|
||||
// Получаем все рубрики поста
|
||||
$categories = get_the_category($post->ID);
|
||||
if (empty($categories)) return $template;
|
||||
|
||||
// Проверяем каждую рубрику поста
|
||||
foreach ($categories as $category) {
|
||||
// Получаем родительскую рубрику (как в category_template)
|
||||
$parent_category = $category->parent
|
||||
? get_category($category->parent)
|
||||
: $category;
|
||||
|
||||
// Если рубрика в списке целевых
|
||||
if (in_array($parent_category->slug, $target_parent_slugs)) {
|
||||
// Ищем шаблон single-{родительская-рубрика}.php
|
||||
$new_template = locate_template("single-{$parent_category->slug}.php");
|
||||
if ($new_template) return $new_template;
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
});
|
||||
58
partials/forest-informer.php
Normal file
58
partials/forest-informer.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// Задаем ID нужной категории (родительской)
|
||||
$parent_cat_id = 3691; // замените на нужный ID рубрики
|
||||
|
||||
// Получим ID подкатегорий
|
||||
$subcats = get_categories( array(
|
||||
'child_of' => $parent_cat_id,
|
||||
'hide_empty' => false,
|
||||
) );
|
||||
|
||||
// Собираем все ID: родительская + подкатегории
|
||||
$category_ids = array( $parent_cat_id );
|
||||
foreach ( $subcats as $cat ) {
|
||||
$category_ids[] = $cat->term_id;
|
||||
}
|
||||
|
||||
// Получаем 3 случайных поста из этих категорий
|
||||
$params = array(
|
||||
'category__in' => $category_ids,
|
||||
'posts_per_page' => 3,
|
||||
'post_status' => 'publish',
|
||||
'orderby' => 'rand',
|
||||
'date_query' => array(
|
||||
array(
|
||||
'after' => '3 month ago',
|
||||
'inclusive' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
$random_posts = get_posts( $params );
|
||||
|
||||
// Если нашли посты
|
||||
if ( $random_posts ) {
|
||||
// Выбираем случайный один из трёх
|
||||
$post = $random_posts[ array_rand( $random_posts ) ];
|
||||
setup_postdata( $post );
|
||||
?>
|
||||
|
||||
<div class="agro-widget<?if ($args['subclass'] !== '') echo ' '.$args['subclass'];?>">
|
||||
<div class="agro-widget-maintitle"><a href="/forest">Международная научно-практическая конференция<br>«Защита леса — защита будущего»</a></div>
|
||||
<a href="<?php the_permalink(); ?>">
|
||||
<?php if ( has_post_thumbnail() ) : ?>
|
||||
<div>
|
||||
<?php the_post_thumbnail('full'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<h3 class="agro-widget-title"><?php the_title(); ?></h3>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
wp_reset_postdata();
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@@ -19,7 +19,10 @@ if ( in_category('interviews') ) {
|
||||
} else {
|
||||
get_template_part('partials/latest-interview-post');
|
||||
}
|
||||
|
||||
get_template_part('partials/forest-informer');
|
||||
?>
|
||||
|
||||
<?php if (is_front_page()) : ?>
|
||||
<div class="most-read mobile">
|
||||
<div class="most-read__inner">
|
||||
|
||||
94
single-forest.php
Normal file
94
single-forest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php get_header( 'forest' ); ?>
|
||||
|
||||
<?php if (in_category('events')) : ?>
|
||||
<?php get_template_part('single-events'); ?>
|
||||
<? else : ?>
|
||||
<div class="content-middle articles-wrapper">
|
||||
|
||||
<div class="article-single">
|
||||
<div class="article-time article-single__time">
|
||||
<?php if (!in_category('partners')) : ?>
|
||||
<img src="<?= get_asset('/icons/time.svg'); ?>" alt="" />
|
||||
<?php
|
||||
$formatted_date = format_event_date();
|
||||
?>
|
||||
|
||||
<?= $formatted_date; ?>
|
||||
<? endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="article-single__tag"><a href="/forest">Международная научно-практическая конференция «Защита леса — защита будущего»</a></div>
|
||||
|
||||
<h1 class="article-single__title">
|
||||
<?php the_title(); ?>
|
||||
</h1>
|
||||
<?php
|
||||
$author = get_userdata(get_post_field('post_author'));
|
||||
?>
|
||||
|
||||
<?php if (!in_category('partners')) : ?>
|
||||
<?php if ( $author AND $author->display_name !== 'agroexpert.press' ) : ?>
|
||||
<div class="article-author">
|
||||
<div class="article-author__name">
|
||||
<a href="<?= get_author_posts_url($author->ID); ?>">
|
||||
<?= $author->display_name; ?></a><br>
|
||||
<? if ( $author->description !== '' ):?>
|
||||
<?=$author->description?>
|
||||
<?endif?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<div class="article-single__content">
|
||||
<?php
|
||||
//$content = get_the_content();
|
||||
$post_id = get_the_ID();
|
||||
if ( $post_id == 26011 ) {
|
||||
the_content();
|
||||
} else {
|
||||
$content = apply_filters('the_content', get_the_content());
|
||||
echo replace_first_figure_in_content($content);
|
||||
}
|
||||
//the_content(); ?>
|
||||
<div class="article-social">Подписывайтесь на нас в <a href="https://dzen.ru/agroexpert_press?favid=254170145" target="_blank">Дзен</a> и <a href="https://t.me/agroexpert_press" target="_blank">Telegram</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php // get_template_part('partials/rtb-single'); ?>
|
||||
|
||||
<?php get_template_part('partials/featured-posts'); ?>
|
||||
<?php if (!in_category('partners')) : ?>
|
||||
<?php get_template_part('partials/related-posts'); ?>
|
||||
<? else : ?>
|
||||
<div class="section-title">
|
||||
<h2 class="section-title__title subtitle-18">Еще по теме</h2>
|
||||
</div>
|
||||
|
||||
<div class="suggestion-container">
|
||||
<?
|
||||
$args = [
|
||||
'category_name' => 'partners',
|
||||
'post_status' => 'publish',
|
||||
'order' => 'ASC',
|
||||
'posts_per_page' => 4
|
||||
];
|
||||
$posts = get_posts($args);
|
||||
$counter = 0;
|
||||
foreach ($posts as $post) : ?>
|
||||
<div class="suggestion-item">
|
||||
<a href="<?= the_permalink() ?>">
|
||||
<h3 class="subtitle-16"> <?= the_title() ?></h3>
|
||||
</a>
|
||||
</div>
|
||||
<? endforeach; ?>
|
||||
</div>
|
||||
<? endif; ?>
|
||||
<a href="/forest" class="articles-preview__show-next desktop">На главную</a>
|
||||
<div class="articles__spacer-container">
|
||||
<div class="articles__spacer"></div>
|
||||
<div class="articles__spacer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<? endif; ?>
|
||||
|
||||
<?php get_footer( 'forest' ); ?>
|
||||
Reference in New Issue
Block a user