<?php
/**
 * Banner Section
 * 
 * @package furniture_decor
 */
$furniture_decor_banner  = get_theme_mod('furniture_decor_banner_setting', true);
$furniture_decor_banner_button  = get_theme_mod('furniture_decor_section_banner_button_setting', true);
$furniture_decor_args = array(
  'post_type' => 'post',
  'post_status' => 'publish',
  'category_name' => get_theme_mod('furniture_decor_blog_slide_category'),
  'posts_per_page' => 3,
);
$furniture_decor_default_image_url = get_template_directory_uri() . '/images/baner-img.png'; // Update this to the actual path of your default image
?>
<?php if ($furniture_decor_banner) { ?>
<div class="banner">
  <div class="owl-carousel">
    <?php
    $furniture_decor_arr_posts = new WP_Query($furniture_decor_args);
    if ($furniture_decor_arr_posts->have_posts()) :
      while ($furniture_decor_arr_posts->have_posts()) :
        $furniture_decor_arr_posts->the_post();
        ?>
        <div class="banner_inner_box">
          <?php
          if (has_post_thumbnail()) :
            the_post_thumbnail();
          else :
            echo '<img src="' . esc_url($furniture_decor_default_image_url) . '" alt="' . esc_attr__('Default Image', 'furniture-decor') . '">';
          endif;
          ?>
          <div class="banner_box wow zoomIn" data-wow-duration="2s">
            <?php if (get_theme_mod('banner_text_setting')) : ?>
              <p class="custom-banner-text"><?php echo esc_html(get_theme_mod('banner_text_setting')); ?></p>
            <?php endif; ?>
            <h3 class="my-3"><?php the_title(); ?></h3>
            <?php if ($furniture_decor_banner_button) { ?>
              <p class="btn-green">
                <a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php esc_html_e('SHOP COLLECTION', 'furniture-decor'); ?></a>
              </p>
            <?php } ?>
          </div>
        </div>
      <?php
      endwhile;
      wp_reset_postdata();
    endif;
    ?>
  </div>
</div>
<?php } ?>
