Files
dostavka_vodi/wp-content/themes/twentytwentyfour/home.php
2026-04-18 20:18:31 +03:00

105 lines
4.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Blog posts index template for the posts page.
*
* @package Twenty_Twenty_Four
*/
$posts_page_id = (int) get_option( 'page_for_posts' );
$blog_title = $posts_page_id > 0 ? get_the_title( $posts_page_id ) : __( 'Блог', 'twentytwentyfour' );
$blog_intro = $posts_page_id > 0 ? get_post_field( 'post_excerpt', $posts_page_id ) : '';
if ( '' === trim( wp_strip_all_tags( $blog_intro ) ) ) {
$blog_intro = __( 'Пишем о качестве воды, правильном хранении, доставке домой и в офис, а также делимся практическими советами для ежедневного потребления.', 'twentytwentyfour' );
}
$test1_header_action_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : home_url( '/cart/' );
$test1_header_action_label = __( 'Корзина', 'twentytwentyfour' );
$test1_header_mode = 'link';
$test1_header_args = array(
'body_class' => 'test1-shared-shell test1-shared-blog-page',
'header_action_url' => $test1_header_action_url,
'header_action_label' => $test1_header_action_label,
'header_mode' => $test1_header_mode,
);
get_header( 'test1', $test1_header_args );
?>
<main class="site-main" role="main">
<section class="section blog-hero" aria-labelledby="blog-page-title">
<div class="container">
<div class="section-head">
<div>
<span class="eyebrow"><?php esc_html_e( 'Редакция АкваЛиния', 'twentytwentyfour' ); ?></span>
<h1 class="section-title" id="blog-page-title"><?php echo esc_html( $blog_title ); ?></h1>
</div>
<p class="section-copy"><?php echo esc_html( $blog_intro ); ?></p>
</div>
</div>
</section>
<section class="section blog-stream" aria-label="Список статей блога">
<div class="container">
<?php if ( have_posts() ) : ?>
<div class="blog-grid">
<?php
$article_index = 0;
while ( have_posts() ) :
the_post();
$delay_class = $article_index < 5 ? ' reveal-delay-' . $article_index : '';
++$article_index;
?>
<article <?php post_class( 'blog-card reveal' . $delay_class ); ?>>
<a class="blog-card-media" href="<?php the_permalink(); ?>" aria-label="<?php echo esc_attr( wp_strip_all_tags( get_the_title() ) ); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail( 'large', array( 'loading' => 'lazy' ) ); ?>
<?php else : ?>
<?php
$initial = function_exists( 'mb_substr' ) ? mb_substr( get_the_title(), 0, 1 ) : substr( get_the_title(), 0, 1 );
$initial = function_exists( 'mb_strtoupper' ) ? mb_strtoupper( $initial ) : strtoupper( $initial );
?>
<span class="blog-card-placeholder"><?php echo esc_html( $initial ); ?></span>
<?php endif; ?>
</a>
<div class="blog-card-body">
<div class="blog-meta">
<time datetime="<?php echo esc_attr( get_the_date( DATE_W3C ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time>
<?php
$categories = get_the_category();
if ( ! empty( $categories ) ) :
?>
<span><?php echo esc_html( $categories[0]->name ); ?></span>
<?php endif; ?>
</div>
<h2 class="blog-card-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p class="blog-card-excerpt"><?php echo esc_html( wp_trim_words( wp_strip_all_tags( get_the_excerpt() ), 24, '...' ) ); ?></p>
<a class="ghost-button blog-card-link" href="<?php the_permalink(); ?>"><?php esc_html_e( 'Читать статью', 'twentytwentyfour' ); ?></a>
</div>
</article>
<?php endwhile; ?>
</div>
<?php
the_posts_pagination(
array(
'prev_text' => __( 'Назад', 'twentytwentyfour' ),
'next_text' => __( 'Вперед', 'twentytwentyfour' ),
'before_page_number' => '<span class="screen-reader-text">' . __( 'Страница', 'twentytwentyfour' ) . ' </span>',
)
);
?>
<?php else : ?>
<div class="blog-empty-state">
<h2><?php esc_html_e( 'Пока нет статей', 'twentytwentyfour' ); ?></h2>
<p><?php esc_html_e( 'Добавьте первую запись в разделе Записи, и она сразу появится на странице блога.', 'twentytwentyfour' ); ?></p>
</div>
<?php endif; ?>
</div>
</section>
</main>
<?php
get_footer( 'test1' );