<?php
if ( ! get_theme_mod( 'interior_services_enable_slider_section', false ) ) {
	return;
}

$interior_services_slider_category = get_theme_mod( 'interior_services_slider_slider_category', 'slider' );
$interior_services_trending_slider_heading = get_theme_mod( 'interior_services_slider_heading');
$interior_services_args = array(
	'post_type'           => 'post',
	'category_name'       => sanitize_text_field( $interior_services_slider_category ),
	'posts_per_page'      => 6,
	'ignore_sticky_posts' => true,
);

$interior_services_query = new WP_Query( $interior_services_args );

if ( $interior_services_query->have_posts() ) :
	$interior_services_button_label = get_theme_mod( 'interior_services_slider_button_label' );
	$interior_services_button_link  = get_theme_mod( 'interior_services_slider_button_link' );
	$interior_services_button_link  = ! empty( $interior_services_button_link ) ? esc_url( $interior_services_button_link ) : '';
	$interior_services_default_image_url = get_template_directory_uri() . '/resource/img/default.png';
	$interior_services_default_image_url_1 = get_template_directory_uri() . '/resource/img/default.png';
	?>
	<section id="interior_services_slider_section" class="slider-section slider-style-1">
		<?php if ( is_customize_preview() ) : interior_services_section_link( 'interior_services_slider_section' ); endif; ?>
		<div class="slider-section-wrapper">	
			<div class="asterthemes-banner-wrapper banner-slider restaurant-brunch-carousel-navigation">
				<?php
				while ( $interior_services_query->have_posts() ) :
					$interior_services_query->the_post();
					?>
					<div class="slider-single-outer">
						<div class="slider-single">
							<div class="slider-caption">
								<div class="asterthemes-wrapper">
									<div class="slider-catption-wrapper wow zoomIn">
										<?php if ( ! empty( $interior_services_trending_slider_heading ) ) { ?>
											<h3><?php echo esc_html( $interior_services_trending_slider_heading ); ?></h3>
										<?php } ?>
										<h2 class="slider-caption-title">
											<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
										</h2>
										<div class="mag-post-excerpt"><?php the_excerpt(); ?></div>
										<?php if ( ! empty( $interior_services_button_label ) && ! empty( $interior_services_button_link ) ) : ?>
											<div class="banner-slider-btn">
												<a href="<?php echo esc_url( $interior_services_button_link ); ?>" class="asterthemes-button">
													<?php echo esc_html( $interior_services_button_label ); ?>
													<i class="fas fa-arrow-right"></i>
												</a>
											</div>
										<?php endif; ?>
									</div>
								</div>
							</div>
							<div class="slider-img">
								<div class="slider-post-img wow zoomIn">
									<?php
									if ( has_post_thumbnail() ) {
										the_post_thumbnail( 'full' );
									} else {
										echo '<img src="' . esc_url( get_template_directory_uri() . '/resource/img/default.png' ) . '" alt="' . esc_attr( get_the_title() ) . '">';
									}
									?>
								</div>
							</div>
						</div>
					</div>
					<?php
				endwhile;
				wp_reset_postdata();
				?>
			</div>
		</div>
	</section>
<?php endif; ?>