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

$matrimony_history_page  = get_theme_mod('matrimony_history_page',0); 
$matrimonial_history_option = get_theme_mod('matrimonial_history_option', 0 );
if( 0 == $matrimonial_history_option) {
	return;
}
 ?>
<section class="history-section" style="background-image: url('<?php echo esc_url(get_theme_mod('matrimony_history_image','')); ?>') ";">
    <div class="container">
        <div class="history-wrap wow shake" data-wow-duration="1s">
        	<?php   if( !empty( $matrimony_history_page ) ): 
        		$args = array (                                 
        		'page_id'           => absint( $matrimony_history_page ),
        		'post_status'       => 'publish',
        		'post_type'         => 'page',
        		);
        		$loop_portfolio= new WP_Query($args);
        		if ( $loop_portfolio->have_posts() ) : ?>
		            <div class="section-intro animated wow fadeInDown" data-wow-duration="1s">
		            	<?php while ($loop_portfolio->have_posts()) : $loop_portfolio->the_post();?>
			               <header class="entry-header heading">
			                    <h4 class="entry-title"><?php the_title(); ?></h4>
			                </header>
			                <div class="header-img-wrap">
			                    <?php the_post_thumbnail(); ?>
			                </div>
    	                        <?php 
		                        $history_des_option = get_theme_mod('matrimonial_history_page_des_opt', 0 );
		                        if( $history_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;

		    $matrimony_history_cat = get_theme_mod('matrimony_home_section_cat',0); 
		    $matrimony_history_post_num = get_theme_mod('matrimony_history_post_num',5);
		    ?>
            <div class="post-content-wrap animated wow fadeInUp" data-wow-duration="1s">
            	<?php
            	if( !empty( $matrimony_history_cat) ) {
            		$loop = new WP_Query(
            		array(
            			'post_type' => 'post',    
            			'category_name' => esc_html($matrimony_history_cat),
            			'posts_per_page' => absint( $matrimony_history_post_num ),  
            			)
            		);
            	} else{
            		$loop = new WP_Query( 
            		array( 
            			'post_type'=>'post',
            			'posts_per_page' =>absint( $matrimony_history_post_num ), 
            		) );
            	}   
            	if($loop->have_posts() ) :
	            	while($loop->have_posts() ) : $loop->the_post(); ?>
		            	<div class="post-content">
			                    <div class="entry-meta">
		                        <div class="posted-on wow fadeIn" data-wow-duration="1s"> 
		                            <?php matrimony_posted_on();?>
		                        </div>
			                    </div>
			                    <header class="entry-header">
			                        <h2 class="entry-title">
			                           <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
			                        </h2>
			                    </header>
			                    <div class="entry-contain">
			                        <p>
			                            <?php echo esc_html(wp_trim_words(get_the_content(),30,'&hellip;')); ?>
			                        </p>
			                    </div>
		                </div>
           			<?php endwhile;                   	
               	endif;
               	wp_reset_postdata(); 
               	?> 
            </div>
        </div>
    </div>
</section> <!--  blog-section end -->

