<?php
/**
 *
 * @package Luzuk Premium
 */

if(get_theme_mod('blog_section_disable') != 'on' ){ ?>
	<?php 
 	if( get_theme_mod('blog_areaTpadding',true) ) {
 		$blog_areaTpadding = 'padding-top:'.esc_attr(get_theme_mod('blog_areaTpadding')).';';
 	}
 	if( get_theme_mod('blog_areaBpadding',true) ) {
 		$blog_areaBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('blog_areaBpadding')).';';
 	}
 	if( get_theme_mod('blog_areaLpadding',true) ) {
 		$blog_areaLpadding = 'padding-left:'.esc_attr(get_theme_mod('blog_areaLpadding')).';';
 	}
 	if( get_theme_mod('blog_areaRpadding',true) ) {
 		$blog_areaRpadding = 'padding-right:'.esc_attr(get_theme_mod('blog_areaRpadding')).';';
 	}
 	?>
<section id="blog" class="blog-area " style="<?php echo esc_attr($blog_areaTpadding); ?>" "<?php echo esc_attr($blog_areaBpadding); ?>" "<?php echo esc_attr($blog_areaLpadding); ?>" "<?php echo esc_attr($blog_areaRpadding); ?>" "<?php echo esc_attr($blog_areaLpadding); ?>">
 		
			<?php			
 		$blog_title = get_theme_mod('blog_title_title', 'LATEST POST');
 		?>

	<!-- <div class="container"> -->
		<div class="row">
	 		 <div class="ht-section-title-tagline">
	 			<?php if($blog_title){ ?>
	 				<div class="heading-icon-l">
						<i class="fa fa-cog"></i>
					</div>
		 			<div class="section-title ht-border">
		 				<h2><?php echo ($blog_title);  ?></h2>
		 				<div class="title-icon">
			 				<img src="<?php echo esc_html(get_template_directory_uri()); ?>/images/heading-tap.png" />
			 			</div>
	 				</div>
	 				<div class="clearfix"></div>
	 			<?php }?>
	 		</div> 
	 	</div>		
 	<!-- </div> -->
 	<!-- <div class="container">	 -->
 		<div class="row">	
			<div class="blog-area-wrap">
				<div class="blog-posts">
					<?php 
					$blog_post_count = get_theme_mod('blog_post_count', 4 );
					$blog_cat_exclude = get_theme_mod('blog_cat_exclude');
					$blog_cat_exclude = explode(',', $blog_cat_exclude);
					$args = array(
						'posts_per_page' => absint($blog_post_count),
						'category__not_in' => $blog_cat_exclude
					);
					$query = new WP_Query($args);
					if($query -> have_posts()):
						while($query -> have_posts()) : $query -> the_post();
						$lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id() , 'total-blog-thumb');
						?>
						<?php 
						if(has_post_thumbnail()){
							$img = esc_url($lz_fitness_image[0]);
						}
						if(empty($lz_fitness_image)){
							$img = get_template_directory_uri().'/images/blog.jpg';
						}
						?>
					 <div class="blog-post col-md-3 col-sm-6">  
					
							<div class="box-area-S">
								<div class="blog-thumbnail">
									<a href="<?php the_permalink(); ?>"><img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>"></a>
									<div class="ovrlyT"></div>
									<div class="ovrlyB"></div>
									<div class="blog-date">
			                            <!-- <span> <?php echo get_the_date( 'j F, Y' ); ?></span> -->
			                            <li><?php echo get_the_date( 'j' ); ?><br>
											<span><?php echo get_the_date( 'M' ); ?></span>
										</li>
			                        </div>
									
								</div>
								<div class="blog-single">
									<a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
									
									<p><?php 
										if(has_excerpt()){
											echo get_the_excerpt();
										}else{
											echo luzuk_excerpt( get_the_content() , 130 );
										}
									?></p>
									<div class="clearfix"></div>
									
									<div class="blog-btn">
											<a href="<?php the_permalink(); ?>"><?php _e('READ MORE', 'total'); ?></a>
										</div>
									<div class="clearfix"></div>
								</div>
								
							</div>
						
					</div>
						<?php
					endwhile;
				endif;
				wp_reset_postdata();
				?>
				</div>
			</div>
			<div class="clearfix"></div>
			
		</div>
	<!-- </div> -->
	<div class="clearfix"></div>
</section>
<script type="text/javascript">
      var title = 0;
      jQuery(".blog-area .blog-post").each(function(){
        if ($(this).height() > title) { title = $(this).height(); }
      });
      jQuery(".blog-area .blog-post").height(title);


      // on Resize change height

      jQuery(window).resize(function(){
        jQuery(".blog-area .blog-post").height("");
        var title = 0;
        jQuery(".blog-area .blog-post").each(function(){
          if ($(this).height() > title) { title = $(this).height(); }
        });
        jQuery(".blog-area .blog-post").height(title);
      });
  </script>
<?php }