<?php

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

$cleaning_services_agent_args = '';

cleaning_services_agent_render_service_section( $cleaning_services_agent_args );

/**
 * Render Service Section.
 */
function cleaning_services_agent_render_service_section( $cleaning_services_agent_args ) { ?>
	<section id="cleaning_services_agent_trending_section" class="asterthemes-frontpage-section trending-section trending-style-1">
		<div class="asterthemes-wrapper">
			<?php
			if ( is_customize_preview() ) :
				cleaning_services_agent_section_link( 'cleaning_services_agent_service_section' );
			endif;

			$cleaning_services_agent_services_short_heading = get_theme_mod( 'cleaning_services_agent_services_short_heading', '' );
			$cleaning_services_agent_services_heading = get_theme_mod( 'cleaning_services_agent_services_heading', '' );
			$cleaning_services_agent_services_content = get_theme_mod( 'cleaning_services_agent_services_content', '' );
			?>
			<div class="product-contact-inner">
				<?php if ( ! empty( $cleaning_services_agent_services_short_heading || $cleaning_services_agent_services_heading ) ) { ?>
					<div class="section-heading">
						<h4><?php echo esc_html( $cleaning_services_agent_services_short_heading ); ?></h4>
						<h3><?php echo esc_html( $cleaning_services_agent_services_heading ); ?></h3>
					</div>
				<?php } ?>
				<?php if ( ! empty( $cleaning_services_agent_services_content ) ) { ?>
				<div class="section-content">
					<p><?php echo esc_html( $cleaning_services_agent_services_content ); ?></p>
				</div>
				<?php } ?>
			</div>
		   	<?php $cleaning_services_agent_catData = get_theme_mod('cleaning_services_agent_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' => $cleaning_services_agent_catData, // Filter by category slug
	                    'order' => 'ASC'
	                );?>
                <?php $cleaning_services_agent_loop = new WP_Query( $args );
                while ( $cleaning_services_agent_loop->have_posts() ) : $cleaning_services_agent_loop->the_post(); ?>
                    <div class="tab-post wow zoomIn delay-1000" data-wow-duration="2s">
                        <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.png" />
							<?php endif; ?>
                        </figure>
                        <div class="post-content">
                        	<div class="heading-post">
                        		<h5 class="post-text"><a href="<?php echo esc_url(get_permalink( $cleaning_services_agent_loop->post->ID )); ?>"><?php the_title(); ?></a></h5>
                        	</div>
                        	<div class="post-btn">
                        		<a href="<?php echo esc_url(get_permalink( $cleaning_services_agent_loop->post->ID )); ?>"><?php echo esc_html('READ MORE','cleaning-services-agent' ); ?><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
}