<?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_areaTpadding); ?>""<?php echo esc_attr($blog_areaBpadding); ?>" >
	<?php
 			$blog_title = get_theme_mod('blog_title_title', 'LATEST BLOG & ARTICALES');
 	?>
	<div class="container">
		<div class="wow zoomIn" data-wow-duration="1s">
			<!-- <div class="container"> -->
				<div class="row justify-content-center">
					  <div class="section-title">
					    <?php if($blog_title ){ ?>
						    <h2><?php echo ($blog_title);  ?></h2>

			         <?php }?>
			      </div>
				</div>
			<!-- </div> -->
	  </div>
			<!-- <div class="row"> -->
				<div class="blog-area-wrap">

					<?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_image = wp_get_attachment_image_src(get_post_thumbnail_id() , 'total-blog-thumb');
							?>
							<?php
								if(has_post_thumbnail()){
									$img = esc_url($luzuk_image[0]);
								}
								if(empty($luzuk_image)){
									$img = get_template_directory_uri().'/images/blog.jpg';
								}
							?>
					<div class="col-md-4 col-sm-6 col-xs-12 blog-boxs">
						<div class="blog-post wow zoomIn">
							<div class="box-area-S">
								<div class="blog-thumbnail  pd-0">
									<a href="<?php the_permalink(); ?>"><img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>">
									</a>
				        </div>
								<div class="clearfix"></div>
							</div>
							<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">
	                        <li><i class="fa fa-calendar"></i> <?php echo get_the_date( 'j' ); ?>
														<span><?php echo get_the_date( 'M' ); ?></span>
														<?php echo get_the_date( 'Y' ); ?>
													</li>
	                    </div>
		                  <div class="clearfix"></div>
		                  <div class="row blog-authoer-coment">
		                  	<div class="col-md-5 col-sm-5 auther-blog">
		                  		<i class="fa fa-user-o"></i> BY <?php echo get_the_author(); ?>
		                  	</div>
		                  	<div class="col-md-7 col-sm-7 comment-auther">
		                  		<i class="fa fa-comment"></i> <?php echo $my_var = get_comments_number(); ?> COMMENTS
		                  	</div>
		                  </div>
		                  <div class="clearfix"></div>
		                  <div class="blog-border-main"></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() , 80 );
														}
													?>
											</div>
												<?php
                        	$blog_button = get_theme_mod('blog_button', 'Read More');
                    		?>
                      <?php if($blog_button ){ ?>
                      <div class="btn5">
                          <a class="btn btn-lg red" href="<?php the_permalink(); ?>"> 
                            <?php echo $blog_button ?>
                          </a>
                      </div>
                     <?php }?>
									</div>
							</div>
							<div class="clearfix"></div>
							<!-- </div> -->
					</div>
				</div>
							<?php
						endwhile;
					endif;
					wp_reset_postdata();
					?>

					<div class="clearfix"></div>
				</div>
			<!-- </div> -->

	</div>
	<div class="clearfix"></div>
</div>
<script>
  jQuery.noConflict();
  $(function(){
    function blogpostHeight(){
      var ht = 0;
      $('.blog-area .blog-post').each(function(i){
        var tHt = $(this).height();
        if(ht<tHt){
          ht=tHt;
        }
      });
      $('.blog-area .blog-post').height(ht+'px');
    }
    blogpostHeight();
  });
  $( window ).resize(function(){
    blogpostHeight();
  });
</script>
<?php }
