<?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')).';';
 	}
 	
 	?>
<div  class="blog-area" id="blog" style="<?php echo esc_attr($blog_areaTpadding); ?>" "<?php echo esc_attr($blog_areaBpadding); ?>" >	
	<?php			
		$blog_title = get_theme_mod('blog_title', 'Where Passion Meets The Page');
		$blogsubtitle = get_theme_mod('blogsubtitle', 'BLOG');
	?>
		<div class="container">
			<div class="section-title">
					<?php if( $blogsubtitle){ ?>
							<div class="heading-brd"></div>
              <h4 class="section-subtitle">
                  <?php echo ($blogsubtitle);  ?>
              </h4>
          <?php } ?>
          <?php if($blog_title){ ?>	
							<h2><?php echo ($blog_title);  ?></h2>
					<?php }?>
			</div>
			<div class="blog-area-wrap">
				<div class="blog-posts">
					<div class="row">
						<?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();
								$luzuk_blog_image = wp_get_attachment_image_src(get_post_thumbnail_id() , 'total-blog-thumb');
								?>
								<?php 
								if(has_post_thumbnail()){
									$img = esc_url($luzuk_blog_image[0]);
								}
								if(empty($luzuk_blog_image)){
									$img = get_template_directory_uri().'/images/blog.jpg';
								}
						?>
						<div class="blog-post col-lg-4 col-md-6 col-sm-6">
							<div class="box-area-S wow zoomIn">
								<div class="blog-thumbnail">
									<div class="blog-imgarea">
											<div class="blog-ovly"></div>
											<div class="blog-image">
												<a href="<?php the_permalink(); ?>">
													<img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>">
												</a>
											</div>
											<div class="blog-date">
													<span><?php echo get_the_date( 'M' ); ?></span><br>	
													<?php echo get_the_date( 'j, Y' ); ?>
											</div>
									</div>
								</div>		
								<div class="blog-single">
										<a href="<?php the_permalink(); ?>">
											<h4 class="inner-area-title"><?php the_title(); ?></h4>
										</a>
										<p>
											<?php 
													if(has_excerpt()){
														echo get_the_excerpt();
													}else{
														echo luzuk_excerpt( get_the_content() , 150 );
													}
											?>
										</p>
										<?php
			                  $blog_button1 = get_theme_mod('blog_button1', 'View more');
			             	?>
						        <?php if($blog_button1) { ?>
											<div class="blogbtn"> 
                        <a href="<?php echo esc_url(get_permalink()); ?>">
                        	<?php echo $blog_button1 ?>
                        	<svg width="46.28" height="17.828" viewBox="0 0 46.28 17.828">
														  <g id="Icon_feather-arrow-right" data-name="Icon feather-arrow-right" transform="translate(6.541 -6.086)">
														    <path id="Path_216" data-name="Path 216" d="M7.5,18H51.78" transform="translate(-13.041 -3)" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
														    <path id="Path_217" data-name="Path 217" d="M18,7.5,25.5,15,18,22.5" transform="translate(13.239)" fill="none"  stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/>
														  </g>
														</svg>
                        </a>
                    	</div> 
	                 <?php }?>
									<div class="clearfix"></div>
								</div>
								<div class="clearfix"></div>
							</div>
						</div>
					<?php
						endwhile;
						endif;
						wp_reset_postdata();
					?>
				</div>
			</div>
			<div class="clearfix"></div>
		</div>	
	</div>
	<div class="clearfix"></div>
</div>
<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 }