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

/**
 * Render Services Section.
 */ 

 $aster_portfolio_services_section_heading = get_theme_mod( 'aster_portfolio_services_section_heading');
 $aster_portfolio_services_section_content = get_theme_mod( 'aster_portfolio_services_section_content');
 $aster_portfolio_services_short_content = get_theme_mod( 'aster_portfolio_services_short_content');
 ?>
 
 <section id="topservices" class="services-section aster_portfolio_services_section primary">
	 <?php
	 if ( is_customize_preview() ) :
		 aster_portfolio_section_link( 'aster_portfolio_services_section' );
	 endif;
	 ?>
	 <div class="services-section-wrapper">
		 <div class="asterthemes-wrapper">
			 <div class="services-single-outer">
				 <div class="services-single">

					 <div class="services-caption wow fadeInUp delay-1000">
						<div class="services-catption-wrapper">
						 	<p class="services-short-content">
								 <?php echo esc_html( $aster_portfolio_services_short_content ); ?>
							 </p>
							 <h1 class="services-caption-title">
								 <?php echo esc_html( $aster_portfolio_services_section_heading ); ?>
							 </h1>
							 <p class="services-caption-content">
								 <?php echo esc_html( $aster_portfolio_services_section_content ); ?>
							 </p>

						</div>

						<div class="owl-carousel services-slider">
						<?php
							$aster_portfolio_catergory_name = get_theme_mod( 'aster_portfolio_blog_args_' );
							$aster_portfolio_args = array(
								'post_type'           => 'post',
								'category_name'       => $aster_portfolio_catergory_name,
								'orderby'             => 'post__in',
								'ignore_sticky_posts' => true,
							);

							$aster_portfolio_query = new WP_Query( $aster_portfolio_args );
							$aster_portfolio_count = 1;
							$aster_portfolio_i = 1;
							if ( $aster_portfolio_query->have_posts() ) :
							while ( $aster_portfolio_query->have_posts() ) :
								$aster_portfolio_query->the_post();
						?>
							<div class="item">
								<div class="services_box wow zoomIn" data-wow-duration="1.5s">
									<span class="counter">
										<?php echo esc_html( sprintf( '%02d', $aster_portfolio_count ) ); ?>
									</span>
									<div class="image-blog services-image">
									<?php 
									if ( has_post_thumbnail() ) {
										the_post_thumbnail( 'large' );
									} else {

										?>
										<img src="<?php echo esc_url( get_stylesheet_directory_uri() . '/resource/img/default1.png' ); ?>" alt="<?php the_title_attribute(); ?>">
									<?php } ?>

									</div>

									<div class="services_content">
									<div class="services_content_inner">
										<?php if ( get_theme_mod( 'aster_portfolio_category_icon' . $aster_portfolio_i ) != '' ) : ?>
											<span class="post-icon">
												<i class="<?php echo esc_attr( get_theme_mod( 'aster_portfolio_category_icon' . $aster_portfolio_i ) ); ?>"></i>
											</span>
										<?php endif; ?>
										<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
										<p><?php echo esc_html( wp_trim_words( get_the_excerpt(), 15 ) ); ?></p>
									</div>
									</div>

								</div>
							</div>
						<?php
							$aster_portfolio_count++;
							$aster_portfolio_i++;
							endwhile;
							wp_reset_postdata();
							endif;
						?>
						</div>   
					 </div>
				 </div>
			 </div>		
		 </div>
	 </div>
 </section>