<?php
/**
 * Custom Testimonial Funtions
 *
 * @package Matrimony
 */
$matrimonial_testimonial_section_cat = get_theme_mod('matrimonial_testimonial_section_cat',0);
$matrimony_testimonial_post_num = get_theme_mod('matrimony_testimonial_post_num',5);
$matrimonial_testimonial_option = get_theme_mod('matrimonial_testimonial_option', 0 );
if( 0 == $matrimonial_testimonial_option){
	return;
} ?>
<section class="testimonial-section" style="background-image: url('<?php echo esc_url(get_theme_mod('matrimony_testimonial_image','')); ?>') ";>
    <div class="container">
        <div class="testimonial-wrap">
        	<?php
        	if( !empty( $matrimonial_testimonial_section_cat) ) {
        		$loop = new WP_Query(
        		array(
        			'post_type' => 'post',    
        			'category_name' => esc_html($matrimonial_testimonial_section_cat),
        			'posts_per_page' => absint( $matrimony_testimonial_post_num ),  
        			)
        		);
        	}	else{
        		$loop = new WP_Query( 
        			array( 
        				'post_type'=>'post',
        				'posts_per_page'=>absint( $matrimony_testimonial_post_num ), 
        			)
    			);
        	}   
        	if($loop->have_posts() ) :
            	while($loop->have_posts() ) :  $loop->the_post(); ?>
	 	            <div class="testimonial-item animated wow fadeInDown" data-wow-duration="1s">
	 	                <div class="entry-contain">
	 	                    <p> <?php echo esc_html(wp_trim_words(get_the_content(),15,'&hellip;')); ?></p>
	 	                </div>
	 	                <div class="header-img-wrap">
	 	                      <?php the_post_thumbnail(); ?>
	 	                </div>
	 	                <header class="entry-header">
	 	                    <h4 class="entry-title"> 
	 	                    	<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
	 	                    </h4>
	 	                </header>     
	 	            </div>
				<?php endwhile;
				endif;
				wp_reset_postdata();
			?>      
        </div>
    </div>
</section><!-- testimonial-section end -->
