170 lines
7.3 KiB
PHP
170 lines
7.3 KiB
PHP
<?php
|
||
/*
|
||
Template Name: Блог
|
||
*/
|
||
?>
|
||
|
||
|
||
<?php get_header(); ?>
|
||
|
||
<main class="main">
|
||
|
||
<?php
|
||
$current_section = hantico_blog_section();
|
||
$section_urls = [
|
||
'' => home_url('/blog/'),
|
||
'general' => add_query_arg('section', 'general', home_url('/blog/')),
|
||
'taxi' => home_url('/blog-taxi/'),
|
||
'courier' => home_url('/blog-courier/'),
|
||
'cargo' => home_url('/blog-cargo/'),
|
||
];
|
||
$blog_title = get_field('blog_title');
|
||
$blog_descr = get_field('blog_descr');
|
||
$blog_query = hantico_blog_query(true);
|
||
if ($blog_query->have_posts()) :
|
||
?>
|
||
<section class="blog">
|
||
<div class="container">
|
||
<?php if ($blog_title && $blog_descr) : ?>
|
||
<div class="blog-header">
|
||
<div class="blog-info">
|
||
<h1 class="blog-title"><?php echo $blog_title; ?></h1>
|
||
<div class="blog-descr"><?php echo $blog_descr; ?></div>
|
||
</div>
|
||
<div class="blog-logo">
|
||
<img src="<?php echo get_theme_file_uri('assets/img/icons/logo2.svg'); ?>" alt="Hantico" width="112" height="147">
|
||
</div>
|
||
|
||
<div class="blog-header__action">
|
||
<a href="/about/" class="header-buttons__download-btn btn btn--red">О редакции</a>
|
||
</div>
|
||
</div>
|
||
<?php endif; ?>
|
||
|
||
<?php
|
||
if (!is_wp_error($terms)) :
|
||
$blog_url = $section_urls[$current_section];
|
||
?>
|
||
|
||
<nav class="work-directions" aria-label="Разделы блога Hantico">
|
||
<ul class="work-directions__grid">
|
||
<?php
|
||
$directions = [
|
||
'courier' => ['label' => 'Курьерам', 'vehicle' => 'scooter'],
|
||
'taxi' => ['label' => 'Таксистам', 'vehicle' => 'taxi'],
|
||
'cargo' => ['label' => 'Грузоперевозчикам', 'vehicle' => 'van'],
|
||
];
|
||
foreach ($directions as $section => $direction) :
|
||
$is_current = $current_section === $section;
|
||
?>
|
||
<li<?php if ($section === 'cargo') echo ' class="work-directions__cargo"'; ?>>
|
||
<a class="work-directions__card work-directions__card--<?php echo esc_attr($section); ?><?php if ($is_current) echo ' is-active'; ?>" href="<?php echo esc_url($section_urls[$section]); ?>"<?php if ($is_current) echo ' aria-current="page"'; ?>>
|
||
<span class="work-directions__vehicle work-directions__vehicle--<?php echo esc_attr($direction['vehicle']); ?>" aria-hidden="true"><img src="<?php echo esc_url(get_theme_file_uri('assets/img/work-directions/' . $direction['vehicle'] . '.webp')); ?>" alt="" loading="lazy" decoding="async"></span>
|
||
<span class="work-directions__label"><?php echo esc_html($direction['label']); ?></span>
|
||
<span class="work-directions__arrow" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 13 13" fill="none" focusable="false"><path d="M12.5537 7.72367L10.6267 7.71891L10.6369 3.27442L1.36107 12.5326L0.00014086 11.1689L9.25079 1.93597L4.8608 1.92575L4.86557 0.000152722L12.5721 0.0178628L12.5537 7.72367Z" fill="currentColor"/></svg></span>
|
||
</a>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</nav>
|
||
|
||
<div class="blog-slider">
|
||
<div class="blog-slider__container swiper swiper-fade">
|
||
<div class="blog-slider__wrapper swiper-wrapper">
|
||
<?php while ($blog_query->have_posts()) : $blog_query->the_post(); ?>
|
||
<div class="blog-item swiper-slide">
|
||
<div class="blog-item__info">
|
||
<?php
|
||
$terms = get_the_terms(get_the_ID(), 'article_category');
|
||
if ($terms) :
|
||
?>
|
||
<ul class="blog-item__tags">
|
||
<?php foreach ($terms as $term) : ?>
|
||
<li class="blog-item__tag"><?php echo $term->name; ?></li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
<?php endif; ?>
|
||
<div class="blog-item__title">
|
||
<a href="<?php the_permalink(); ?>" class="blog-item__title-link"><?php the_title(); ?></a>
|
||
</div>
|
||
<div class="blog-item__descr"><?php echo get_card_descr('article_descr', 25); ?></div>
|
||
<div class="blog-item__read">
|
||
<a href="<?php the_permalink(); ?>" class="blog-item__read-btn btn btn--md btn--transp-red">Читать статью</a>
|
||
</div>
|
||
</div>
|
||
<div class="blog-item__img">
|
||
<a href="<?php the_permalink(); ?>" class="blog-item__img-link">
|
||
<?php
|
||
echo wp_get_attachment_image(
|
||
get_post_thumbnail_id(),
|
||
'large', false,
|
||
['alt' => get_the_title()]
|
||
);
|
||
?>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
<?php endwhile; wp_reset_postdata(); ?>
|
||
</div>
|
||
</div>
|
||
<div class="blog-slider__pagination swiper-pagination"></div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<?php endif; ?>
|
||
|
||
<?php
|
||
$current_category = isset($_GET['category']) ? sanitize_title($_GET['category']) : '';
|
||
$terms = get_terms([
|
||
'taxonomy' => 'article_category',
|
||
'hide_empty' => true,
|
||
]);
|
||
$blog_query = hantico_blog_query();
|
||
?>
|
||
<section class="articles articles--page">
|
||
<div class="container">
|
||
<h2 class="articles-title articles-title--sm">Все статьи</h2>
|
||
<nav class="articles-filter">
|
||
<ul class="articles-filter__list">
|
||
<li class="articles-filter__item<?php if (!$current_category) echo ' is-active'; ?>">
|
||
<a href="<?php echo $blog_url; ?>" class="articles-filter__link">Все</a>
|
||
</li>
|
||
<?php
|
||
foreach ($terms as $term) :
|
||
$is_active = $current_category === $term->slug;
|
||
$term_url = add_query_arg('category', $term->slug, $blog_url);
|
||
?>
|
||
<li class="articles-filter__item<?php if ($is_active) echo ' is-active'; ?>">
|
||
<a href="<?php echo $term_url; ?>" class="articles-filter__link"><?php echo $term->name; ?></a>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ul>
|
||
</nav>
|
||
<?php endif; ?>
|
||
<div
|
||
class="articles-grid"
|
||
data-page="1"
|
||
data-section="<?php echo esc_attr($current_section); ?>"
|
||
data-max-pages="<?php echo $blog_query->max_num_pages; ?>"
|
||
data-category="<?php echo $current_category; ?>"
|
||
>
|
||
<?php
|
||
if (!$blog_query->have_posts()) echo '<p>Статьи не найдены.</p>';
|
||
while ($blog_query->have_posts()) {
|
||
$blog_query->the_post();
|
||
get_template_part('template-parts/articles-item');
|
||
} wp_reset_postdata();
|
||
?>
|
||
</div>
|
||
<div class="articles-showmore is-hidden">
|
||
<button class="articles-showmore__btn btn btn--lg btn--red">Показать еще</button>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<?php get_template_part('template-parts/socials'); ?>
|
||
<?php get_template_part('template-parts/getapp'); ?>
|
||
|
||
</main>
|
||
|
||
<?php get_footer(); ?>
|