<?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', '<span>OUR</span> BLOG');
 		?>
		<div class="container">
				<div class="row justify-content-center">
					<?php if($blog_title){ ?>	
						<div class="section-title">
							<?php if(!empty($blog_title)){ ?>
								<h1><?php echo ($blog_title);  ?></h1>
							<?php }?> 
						</div>
					<?php }?>
				</div>
		</div>
		<div class="container">
				<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();
								$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.png';
								}
						?>
								<div class="blog-post col-md-4 col-sm-6 pd-2">
										<div class="box-area-S wow bounceInLeft">
												<div class="blog-thumbnail">
														<a href="<?php the_permalink(); ?>">
																<img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>">
																<div class="overlay"></div>
								            </a>
								            <div class="blog-date">
								            	<div class="blog-dbg"></div>
																<div class="col-md-6 col-sm-6 col-xs-6 date">
																		<i class="fa fa-calendar"></i><?php echo get_the_date( 'M j, Y' ); ?>
								            		</div>
								                <div class="col-md-6 col-sm-6 col-xs-6 comments">
								                	<i class="fa fa-commenting" aria-hidden="true"></i><?php echo $my_var = get_comments_number(); ?> Comments
								                		<!-- <i class="fa fa-user" aria-hidden="true"></i><?//php echo get_the_author(); ?> -->
								                </div> 
								            </div>

												</div>
												<div class="blog-single">
								            <div class="clearfix"></div>
														<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() , 115 );
																		}
																?>
														</p>
													<?php
			                        $blog_button1 = get_theme_mod('blog_button1', 'Read More');
			                    ?>
		                    <?php if($blog_button1) { ?>
														<div class="blogbtn"> 
			                          <a class="btn btn-lg" href="<?php echo esc_url(get_permalink()); ?>">
			                             <span>  <?php echo $blog_button1 ?></span>
			                          </a>
			                      </div> 
	                       <?php }?>
													<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 class="clearfix"></div>
</div>
<script>
  jQuery.noConflict();
  $(function(){
    function blogsingleHeight(){
      var ht = 0;
      $('.blog-area .blog-single').each(function(i){
        var tHt = $(this).height();
        if(ht<tHt){
          ht=tHt;
        }
      });
      $('.blog-area .blog-single').height(ht+'px');
    }
    blogsingleHeight();
  });
  $( window ).resize(function(){
    blogsingleHeight();
  });
</script>

<?php }