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

if(get_theme_mod('blog_area_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')).';';
 	}
 	?>
<div  class="blog-area" id="blog" style="<?php echo esc_attr($blog_areaBpadding); ?>" >
	<div class="border-blog" style="<?php echo esc_attr($blog_areaTpadding); ?>"></div>
		<?php			
 			$blog_subtitle = get_theme_mod('blog_title_subtitle', 'Heading Here');
 			$blog_title = get_theme_mod('blog_title_title', 'BLOG POST');
 		?>

			<div class="container">
				    <?php if($blog_title || $blog_subtitle){ ?>
				    <div class="section-heading">
				        <div class="heading-inn">
				        	<p><?php echo ($blog_subtitle);  ?></p>
				        	<h2><?php echo ($blog_title);  ?></h2>
				        </div> 
				    </div>
				    <?php }?>
				<div class="clearfix"></div>
				<div class="blog-circle">
				      <?php 
				        $blogcircle_image = get_theme_mod('blogcircle_image');
				        if(!empty($blogcircle_image)){
				          echo '<img alt="'. esc_html(get_the_title()) .'" src="'.esc_url($blogcircle_image).'" class="img-responsive secondry-bg-img" />';
				        }else{
				          echo '<img alt="sldercircle sign" src="'.get_template_directory_uri().'/images/seccircle.png" class="img-responsive" />';
				        }
				      ?>
				</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', 3 );
						$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/default-gray.png';
								}
								?>
								<div class="blog-post col-md-4 col-sm-6 col-xs-12">
									<div class="box-area-S">
										<a href="<?php the_permalink(); ?>">
											<div class="blog-thumbnail">
												<img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>">
											</div>
										</a>
										<div class="blog-single">

											<?php 
												$blog_page_id = get_theme_mod('blog_page');	
												$blog_inn_image = get_theme_mod('blog_inn_image');
											?>
											<div class="blog-single-img">
												<div class="blog-date ">
													<div class="blog-dateinn col-md-4 pd-0">
														<li><div class="col-md-4 col-sm-2 col-xs-3 pd-0"><span><?php echo get_the_date( 'j' ); ?></span></div>
															<div class=" col-md-8 col-sm-2 col-xs-9"><?php echo get_the_date( 'M' ); ?>
															<?php echo get_the_date( 'Y' ); ?></div>
														</li>
													</div>
													<div class="blog-comm col-md-8">
														<i class="fa fa-comments-o" aria-hidden="true"></i>comments
													</div>
													<div class="clearfix"></div>
						                        </div>
						    

												<a href="<?php the_permalink(); ?>"><h4 class="inner-area-title"><?php the_title(); ?></h4></a>
												<div class="section-area-text">
												<?php 
													if(has_excerpt()){
														echo get_the_excerpt();
													}else{
														echo luzuk_excerpt( get_the_content() , 130 );
													}
												?>

												</div>
											
											</div>
											<div class="clearfix"></div>
											<?php if( get_theme_mod('blog_button_display','show' ) == 'show') :
											?>
											<?php
												$blog_page_id = get_theme_mod('blog_page'); 
												$blogbutn_text = get_theme_mod('blogbutn_text', 'READ MORE');
												?>

											<div class="blog-read-more">
												<a href="<?php the_permalink(); ?>"><?php echo $blogbutn_text; ?> <i class="fa fa-angle-double-right" aria-hidden="true"></i>
												</a>
											</div>
											<?php endif ?>
											<div class="clearfix"></div>
										</div>
										<div class="clearfix"></div>
									</div>
								</div>
								<?php
							endwhile;
						endif;
						wp_reset_postdata();
						?>
					</div>
						<div class="clearfix"></div>
					</div>	
				</div>

			</div>
		<!-- </div> -->
		<div class="clearfix"></div>
		
</div>
<script type="text/javascript">
	var title = 0;
jQuery(".blog-area .box-area-S").each(function(){
  if ($(this).height() > title) { title = $(this).height(); }
});
jQuery(".blog-area .box-area-S").height(title);


// on Resize change height

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

<?php }