<?php get_header(); 
$cat_tit = get_queried_object()->name;
$cat_id = get_queried_object()->term_id;
$gallery = get_field('gallery', 'category_'.$cat_id);
$alt_tit = get_field('alt_tit', 'category_'.$cat_id);
$alt_desc = get_field('alt_desc', 'category_'.$cat_id);
$current_lang = pll_current_language();
?>
<section class="section catalog">
    <div class="container">
            <div class="catalog-row">
        <div class="breadcrumbs">
            <?php if(function_exists('bcn_display')) { bcn_display(); }?>
        </div>
        <div class="catalog-body">
            <div class="catalog-top">
                <h1 class="catalog-top__title">
                    <?php echo $alt_tit ? $alt_tit : $cat_tit; ?>
                </h1>
                <div class="catalog-top__text">
                    <?php echo $alt_desc ? $alt_desc : category_description(); ?>                            
                </div>
            </div>
            <div class="catalog-content">
    <?php if (have_posts()) { while (have_posts()) { the_post(); 
     if ( has_post_thumbnail() ) { 
      $url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post');
      $thmb = $url[0];
        } else {
          $thmb = TEMPLATE_DIR . "/img/main/placeholder.webp";
    }
    $alt_tit = get_field('alt_tit');
    $alt_desc = get_field('alt_desc');
    $gost = get_field('gost');
    $params = get_field('params');
    ?>
    <a href="<?php the_permalink(); ?>" class="production-block catalog-block">
        <div class="production-block__img">
            <img src=" <?php echo $thmb; ?>" alt="<?php the_title(); ?>">
        </div>
        <h3 class="production-block__title">
            <?php the_title(); ?>

        </h3>
        <p class="production-block__text">
            <?php echo $gost?>
        </p>
        <div class="production-block__parameters">
            <?php foreach ($params as $p) {?>
            <div class="production-block__parameters-item">
                <p>
                    <?php echo $p['par_name'];?>
                </p>
                <p>
                    <?php echo $p['par_value'];?>
                </p>
            </div>
            <?php } ?>
        </div>
        <div class="production-block__wrap">
            <h3 class="production-block__title">
                <?php the_title(); ?>

            </h3>
            <div class="production-block__desc">
                <?php echo $alt_desc ? $alt_desc : ''; ?>
            </div>
        </div>
    </a>
    <?php } ?>
    </div>
    <!-- <div class="pagination">
            <?php the_posts_pagination(); ?>
            <a href="#" class="catalog-button__all">
            <?php if ($current_lang === 'ru') { echo 'Смотреть еще'; } else { echo 'Show more'; }?> 
                        </a>
        </div> -->
    <?php } else { ?>
        <p>Записей в этой категории не найдено.</p>
    <?php } ?>
</div>
        </div>
    </div>
</section>
<?php include_once('tpl-footerform.php'); ?>
<?php get_footer(); ?>