<?php
/**
 * Banner Section
 * 
 * @package architecture_construction
 */
$architecture_construction_slider = get_theme_mod('architecture_construction_slider_setting', false);
$architecture_construction_slider_button = get_theme_mod('architecture_construction_slider_button_setting', false);
$architecture_construction_default_image_url = get_template_directory_uri() . '/images/banner-default.jpg'; // Replace with the correct path to your default image

$architecture_construction_args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'category_name' => get_theme_mod('architecture_construction_blog_slide_category'),
    'posts_per_page' => 3,
); ?>

<?php if ($architecture_construction_slider) { ?>
    <div class="banner">
        <div class="owl-carousel">
            <?php
            $architecture_construction_arr_posts = new WP_Query($architecture_construction_args);
            if ($architecture_construction_arr_posts->have_posts()) :
                while ($architecture_construction_arr_posts->have_posts()) :
                    $architecture_construction_arr_posts->the_post();
                    ?>
                    <div class="banner_inner_box">
                        <?php
                        if (has_post_thumbnail()) :
                            the_post_thumbnail();
                        else :
                            echo '<img src="' . esc_url($architecture_construction_default_image_url) . '" alt="' . esc_attr(get_the_title()) . '">';
                        endif;
                        ?>
                        <div class="banner_box <?php echo esc_attr(get_theme_mod('slider_text_alignment', 'right')); ?> wow zoomInUp" data-wow-duration="2s">
                            <h3 class="my-3"><?php the_title(); ?></h3>
                            <p class="mb-0"><?php echo wp_trim_words(get_the_content(), 30); ?></p>
                            <?php if ($architecture_construction_slider_button) { ?>
                                <p class="btn-green mt-4">
                                    <a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php esc_html_e('LEARN MORE', 'architecture-construction'); ?></a>
                                </p>
                            <?php } ?>
                        </div>
                    </div>
                <?php
                endwhile;
                wp_reset_postdata();
            endif; ?>
        </div>
    </div>
<?php } ?>
