<?php

if ( ! get_theme_mod( 'roof_water_proofing_enable_service_section', false ) ) {
	return;
}

$roof_water_proofing_args = '';

roof_water_proofing_render_service_section( $roof_water_proofing_args );

/**
 * Render Service Section.
 */
function roof_water_proofing_render_service_section( $roof_water_proofing_args ) { ?>
	<section id="roof_water_proofing_trending_section" class="asterthemes-frontpage-section trending-section trending-style-1">
		<div class="asterthemes-wrapper">
			<?php
			if ( is_customize_preview() ) :
				roof_water_proofing_section_link( 'roof_water_proofing_service_section' );
			endif;

			$roof_water_proofing_services_short_heading = get_theme_mod( 'roof_water_proofing_services_short_heading', '' );
			$roof_water_proofing_services_heading = get_theme_mod( 'roof_water_proofing_services_heading', '' );
			$roof_water_proofing_services_content = get_theme_mod( 'roof_water_proofing_services_content', '' );
			?>
			<div class="product-contact-inner">
				<?php if ( ! empty( $roof_water_proofing_services_short_heading || $roof_water_proofing_services_heading ) ) { ?>
					<div class="section-heading">
						<h4><?php echo esc_html( $roof_water_proofing_services_short_heading ); ?></h4>
						<h3><?php echo esc_html( $roof_water_proofing_services_heading ); ?></h3>
					</div>
				<?php } ?>
				<?php if ( ! empty( $roof_water_proofing_services_content ) ) { ?>
				<div class="section-content">
					<p><?php echo esc_html( $roof_water_proofing_services_content ); ?></p>
				</div>
				<?php } ?>
			</div>
		   	<?php $roof_water_proofing_catData = get_theme_mod('roof_water_proofing_trending_post_category','Services'); ?>
	        <div class="owl-carousel">
		        <?php  $args = array(
	                    'post_type' => 'post', // Changed from 'product' to 'post'
	                    'posts_per_page' => 9,
	                    'category_name' => $roof_water_proofing_catData, // Filter by category slug
	                    'order' => 'ASC'
	                );?>
                <?php $roof_water_proofing_loop = new WP_Query( $args );
                while ( $roof_water_proofing_loop->have_posts() ) : $roof_water_proofing_loop->the_post(); ?>
                    <div class="tab-post">
                        <figure>
                            <?php if ( has_post_thumbnail() ) : ?>
							    <?php the_post_thumbnail( 'full' ); ?>
							<?php else : ?>
							    <img src="<?php echo esc_url( get_template_directory_uri() ); ?>/resource/img/default.jpg" alt="Default Image" />
							<?php endif; ?>
                        </figure>
                        <div class="post-content">
                        	<div class="heading-post">
                        		<h5 class="post-text"><a href="<?php echo esc_url(get_permalink( $roof_water_proofing_loop->post->ID )); ?>"><?php the_title(); ?></a></h5>
                        	</div>
                        	<div class="post-btn">
                        		<a href="<?php echo esc_url(get_permalink( $roof_water_proofing_loop->post->ID )); ?>"><?php echo esc_html('READ MORE','roof-water-proofing' ); ?><svg xmlns="http://www.w3.org/2000/svg" height="1.5em" viewBox="0 0 448 512"><!--!Font Awesome Free 7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6 .1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z"/></svg></a>
                        	</div>
                        </div>
                    </div>
                <?php endwhile; wp_reset_postdata(); ?>
		    </div>
		</div>	    	
	</section>
	<?php
}