<?php
/**
 * Custom Service Funtions
 *
 * @package Matrimony
 */

$matrimony_service_page  = get_theme_mod('matrimony_service_page',0); 
$matrimonial_service_option = get_theme_mod('matrimonial_service_option', 0 );
$matrimonial_service_section_cat = get_theme_mod('matrimonial_service_section_cat',0);
$matrimony_service_post_num = get_theme_mod('matrimony_service_post_num',5);
if( 0 == $matrimonial_service_option ){
	return;
} ?>
<section class="service-section default-padding">
    <div class="container">
    	<?php   if( !empty( $matrimony_service_page ) ): 
    		$args = array (                                 
    		'page_id'           => absint( $matrimony_service_page ),
    		'post_status'       => 'publish',
    		'post_type'         => 'page',
    		);
    		$loop= new WP_Query($args);
    		if ( $loop->have_posts() ) : ?>
		        <div class="section-intro">
		        	<?php while ($loop->have_posts()) : $loop->the_post();?>
			            <header class="entry-header heading animated wow fadeInDown" data-wow-duration="1s">
			                <h4 class="entry-title"><?php the_title(); ?></h4>
			            </header>
			            <div class="header-img-wrap">
			                <?php the_post_thumbnail(); ?>
			            </div>
                        <?php 
                        $service_des_option = get_theme_mod('matrimonial_service_dec_option', 0 );
                        if( $service_des_option == '1' ):
                    	?>
							<div class="section-description animated wow fadeInUp" data-wow-duration="1s">
								<p> <?php echo esc_html(wp_trim_words(get_the_content(),30,'&hellip;')); ?></p>
							</div>
	                    <?php endif; ?>
	         		<?php endwhile; ?>    		 
		        </div>
	     	<?php endif;
	     	wp_reset_postdata();
	    endif; ?> 
     	<?php
     	if( !empty( $matrimonial_service_section_cat) ) {
     		$loop = new WP_Query(
     		array(
     			'post_type' => 'post',    
     			'category_name' => esc_html($matrimonial_service_section_cat),
     			'posts_per_page' => absint( $matrimony_service_post_num ),  
     			)
     		);
     	} else{
	     	$loop = new WP_Query( 
	     		array( 
	     			'post_type'=>'post',
	     			'posts_per_page'=>absint( $matrimony_service_post_num ), 
	     		) 
	     	);
     	} ?>  
		<div class="service-wrap">
			<?php	
			if($loop->have_posts() ) :
				while($loop->have_posts() ) : $loop->the_post(); ?>
					<div class="service-item animated wow fadeInUp" data-wow-duration="1s">
						<div class="service-icon">
							<?php the_post_thumbnail(); ?>
						</div>
						<h4 class="entry-title">
							<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
						</h4>
						<div class="entry-content">
							<p><?php echo esc_html(wp_trim_words(get_the_content(),30,'&hellip;')); ?></p>
						</div>
					</div>
				<?php 
				endwhile;		
			endif;
			wp_reset_postdata(); ?>  	      
		</div>
           
    </div>
</section><!--  service-section end -->
