HEX
Server: LiteSpeed
System: Linux prometheus.hongkongserver.net 4.18.0-553.134.1.el8_10.x86_64 #1 SMP Tue Jun 16 16:05:57 EDT 2026 x86_64
User: ayxmplky (1112)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/ayxmplky/public_html/wp-content/themes/tactic/archive.php
<?php
/**
 * archive.php — архив постов, таксономий и CPT
 *
 * @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-archive" role="main">
	<?php if ( is_post_type_archive( 'tactic_news' ) ) : ?>
		<?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] ?? $showcase_featured;
		$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>

				<?php // Кнопка "View all news" скрыта по задаче для страницы /news. ?>
			</div>
		</section>
	<?php endif; ?>

	<div class="container">

		<?php if ( ! is_post_type_archive( 'tactic_news' ) ) : ?>
			<header class="archive__header">
				<h1 class="archive__title">
					<?php
					if ( is_category() ) {
						single_cat_title();
					} elseif ( is_tag() ) {
						single_tag_title();
					} elseif ( is_post_type_archive() ) {
						post_type_archive_title();
					} elseif ( is_date() ) {
						echo esc_html( get_the_date( tactic_s( 'archive_date_format' ) ) );
					} else {
						echo esc_html( tactic_s( 'archive_default_title' ) );
					}
					?>
				</h1>
				<?php if ( get_the_archive_description() ) : ?>
					<p class="archive__subtitle"><?php echo wp_kses_post( get_the_archive_description() ); ?></p>
				<?php endif; ?>
			</header>
		<?php endif; ?>

		<?php if ( have_posts() ) : ?>

			<?php if ( is_post_type_archive( 'tactic_news' ) ) : ?>
				<section class="news-archive-articles" aria-label="<?php echo esc_attr( tactic_s( 'archive_articles_aria' ) ); ?>">
					<h2 class="news-archive-articles__title"><?php echo esc_html( tactic_s( 'news_archive_articles_title' ) ); ?></h2>
					<p class="news-archive-articles__subtitle"><?php echo esc_html( tactic_s( 'news_archive_articles_subtitle' ) ); ?></p>

					<?php
					$news_archive_posts = [];
					while ( have_posts() ) : the_post();
						if ( ! tactic_is_valid_blog_card_post( (int) get_the_ID() ) ) {
							continue;
						}
						$news_archive_posts[] = get_post( get_the_ID() );
					endwhile;
					?>

					<div class="news-archive-articles__list">
						<?php foreach ( $news_archive_posts as $news_archive_post ) : ?>
							<?php setup_postdata( $news_archive_post ); ?>
							<a href="<?php echo esc_url( get_permalink( $news_archive_post->ID ) ); ?>" class="news-archive-article">
								<div class="news-archive-article__content">
									<time class="news-archive-article__date" datetime="<?php echo esc_attr( get_the_date( 'Y-m-d', $news_archive_post->ID ) ); ?>"><?php echo esc_html( get_the_date( 'd.m.Y', $news_archive_post->ID ) ); ?></time>
									<h3 class="news-archive-article__name"><?php echo esc_html( get_the_title( $news_archive_post->ID ) ); ?></h3>
									<p class="news-archive-article__excerpt"><?php echo esc_html( get_the_excerpt( $news_archive_post->ID ) ); ?></p>
								</div>
								<div class="news-archive-article__thumb" aria-hidden="true">
									<?php if ( has_post_thumbnail( $news_archive_post->ID ) ) : ?>
										<?php echo get_the_post_thumbnail( $news_archive_post->ID, 'tactic-news-list', [ 'loading' => 'lazy' ] ); ?>
									<?php else : ?>
										<div class="news-archive-article__thumb-placeholder"></div>
									<?php endif; ?>
								</div>
							</a>
						<?php endforeach; ?>
						<?php wp_reset_postdata(); ?>
					</div>

					<?php
					$news_pagination = paginate_links( [
						'type'      => 'array',
						'prev_text' => '‹',
						'next_text' => '›',
						'mid_size'  => 1,
						'end_size'  => 1,
					] );
					?>
					<?php if ( ! empty( $news_pagination ) ) : ?>
						<nav class="pagination pagination--news" aria-label="<?php echo esc_attr( tactic_s( 'common_page_navigation_aria' ) ); ?>">
							<?php foreach ( $news_pagination as $news_page_link ) : ?>
								<?php echo wp_kses_post( $news_page_link ); ?>
							<?php endforeach; ?>
						</nav>
					<?php endif; ?>
				</section>
			<?php else : ?>

			<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' => '›' ] ); ?>
			</nav>

			<?php endif; ?>

		<?php else : ?>
			<p><?php echo esc_html( tactic_s( 'common_no_content' ) ); ?></p>
		<?php endif; ?>

	</div>
</main>
<?php get_footer(); ?>