File: /home/ayxmplky/public_html/wp-content/themes/tactic/index.php
<?php
/**
* index.php — список блога
*
* @package tactic
*/
get_header();
?>
<section class="news-archive-hero" style="background-image:url('<?php echo esc_url( TACTIC_URI . '/assets/images/news-archive-hero.png' ); ?>')">
<div class="news-archive-hero__overlay" aria-hidden="true"></div>
<div class="news-archive-hero__container">
<h1 class="news-archive-hero__title"><?php echo esc_html( tactic_s( 'news_hero_title' ) ); ?></h1>
<p class="news-archive-hero__subtitle"><?php echo esc_html( tactic_s( 'news_hero_subtitle' ) ); ?></p>
</div>
</section>
<main id="main-content" class="page-blog" role="main">
<?php
$news_showcase_posts = get_posts( tactic_apply_news_lang_to_query_args( [
'post_type' => [ 'tactic_news', 'post' ],
'posts_per_page' => 8,
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
] ) );
$news_showcase_posts = array_values( array_filter( $news_showcase_posts, static function ( $post ): bool {
return tactic_is_valid_blog_card_post( (int) $post->ID );
} ) );
$showcase_featured = $news_showcase_posts[0] ?? null;
$showcase_second = $news_showcase_posts[1] ?? null;
$all_news_url = get_post_type_archive_link( 'tactic_news' ) ?: home_url( '/news/' );
?>
<section class="news-archive-showcase" aria-label="<?php echo esc_attr( tactic_s( 'archive_news_showcase_aria' ) ); ?>">
<div class="news-archive-showcase__inner">
<h2 class="news-archive-showcase__title"><?php echo esc_html( tactic_s( 'news_title' ) ); ?></h2>
<p class="news-archive-showcase__subtitle"><?php echo esc_html( tactic_s( 'news_subtitle' ) ); ?></p>
<div class="news-archive-showcase__grid">
<?php if ( $showcase_featured ) : ?>
<a href="<?php echo esc_url( get_permalink( $showcase_featured->ID ) ); ?>" class="news-card news-card--featured">
<div class="news-card__image">
<?php if ( has_post_thumbnail( $showcase_featured->ID ) ) : ?>
<?php echo get_the_post_thumbnail( $showcase_featured->ID, 'tactic-news-thumb', [ 'loading' => 'lazy', 'alt' => esc_attr( $showcase_featured->post_title ) ] ); ?>
<?php else : ?>
<div class="news-card__image-placeholder" aria-hidden="true"></div>
<?php endif; ?>
</div>
<div class="news-card__overlay">
<time class="news-card__date" datetime="<?php echo esc_attr( get_the_date( 'Y-m-d', $showcase_featured->ID ) ); ?>"><?php echo esc_html( get_the_date( 'd.m.Y', $showcase_featured->ID ) ); ?></time>
<h3 class="news-card__title"><?php echo esc_html( $showcase_featured->post_title ); ?></h3>
<span class="news-card__arrow" aria-hidden="true">→</span>
</div>
</a>
<?php endif; ?>
<?php if ( $showcase_second ) : ?>
<a href="<?php echo esc_url( get_permalink( $showcase_second->ID ) ); ?>" class="news-card news-card--featured">
<div class="news-card__image">
<?php if ( has_post_thumbnail( $showcase_second->ID ) ) : ?>
<?php echo get_the_post_thumbnail( $showcase_second->ID, 'tactic-news-thumb', [ 'loading' => 'lazy', 'alt' => esc_attr( $showcase_second->post_title ) ] ); ?>
<?php else : ?>
<div class="news-card__image-placeholder" aria-hidden="true"></div>
<?php endif; ?>
</div>
<div class="news-card__overlay">
<time class="news-card__date" datetime="<?php echo esc_attr( get_the_date( 'Y-m-d', $showcase_second->ID ) ); ?>"><?php echo esc_html( get_the_date( 'd.m.Y', $showcase_second->ID ) ); ?></time>
<h3 class="news-card__title"><?php echo esc_html( $showcase_second->post_title ); ?></h3>
<span class="news-card__arrow" aria-hidden="true">→</span>
</div>
</a>
<?php endif; ?>
</div>
<a href="<?php echo esc_url( $all_news_url ); ?>" class="btn btn--dark news-archive-showcase__all-btn">
<?php echo esc_html( tactic_s( 'news_all_btn' ) ); ?> <span aria-hidden="true">→</span>
</a>
</div>
</section>
<div class="container">
<?php if ( have_posts() ) : ?>
<div class="posts-grid">
<?php while ( have_posts() ) : the_post(); ?>
<?php if ( ! tactic_is_valid_blog_card_post( (int) get_the_ID() ) ) { continue; } ?>
<a href="<?php the_permalink(); ?>" class="post-card">
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-card__image">
<?php the_post_thumbnail( 'tactic-news-list', [ 'loading' => 'lazy' ] ); ?>
</div>
<?php endif; ?>
<div class="post-card__body">
<time class="post-card__date" datetime="<?php echo esc_attr( get_the_date( 'Y-m-d' ) ); ?>">
<?php echo esc_html( get_the_date( 'd.m.Y' ) ); ?>
</time>
<h2 class="post-card__title"><?php the_title(); ?></h2>
<p class="post-card__excerpt"><?php the_excerpt(); ?></p>
<span class="post-card__more"><?php echo esc_html( tactic_s( 'common_read_more' ) ); ?></span>
</div>
</a>
<?php endwhile; ?>
</div>
<nav class="pagination" aria-label="<?php echo esc_attr( tactic_s( 'common_page_navigation_aria' ) ); ?>">
<?php
echo paginate_links( [
'prev_text' => '‹',
'next_text' => '›',
'type' => 'list',
] );
?>
</nav>
<?php else : ?>
<p><?php echo esc_html( tactic_s( 'common_no_content' ) ); ?></p>
<?php endif; ?>
</div>
</main>
<?php get_footer(); ?>