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

if(get_theme_mod('blog_section_disable') != 'on' ){ ?>
	<section id="ht-blog-section" class="ht-section">
		<div class="container">
			<div class=" wow fadeInUp" data-wow-duration="1s">
				<?php
				$blog_title = get_theme_mod('blog_title', 'RECENT BLOGS');
				?>
				<?php if($blog_title){ ?>
					<div class="row">
						<div class="ht-section-title-tagline">
							<?php if($blog_title){ ?>
								<h2 class="ht-section-title lz-blog-heading"><?php echo ($blog_title); ?></h2>
							<?php } ?>
							<div class="titleborder"></div>
							<div class="border-separator-outer">
								<div class="outerborder-separator"></div>
						        <div class="innerborder-separator"></div>
						    </div>
						</div>
						
					<?php } ?>
					<div class="clearfix"></div>
					</div>
					<div class="row">
					<div class="ht-blog-wrap">
						<div class="ht-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_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="ht-blog-post col-md-4 col-sm-6">
									<div class="box-panels">

										<div class="ht-blog-thumbnail">
											<a href="<?php the_permalink(); ?>"><img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>"></a>
										</div>
										<div class="blog-read-more">
													<a href="<?php the_permalink(); ?>"><i class="fa fa-long-arrow-right" aria-hidden="true"></i></a>
												</div>
										<div class="ht-blog-excerpt">

											<h5><?php the_title(); ?></h5>

											 <div class="ht-blog-date">
					                            <div class="userb col-md-6 padding0">
					                              <?php echo get_the_author(); ?>
					                            </div>
					                            <div class="userdate col-md-6 padding0">
					                            <?php echo get_the_date( 'j F Y' ); ?>
					                            </div>
					                        </div>
											<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>
</section>
<script>
  jQuery.noConflict();
  $(function(){
    function boxpanelsHeight(){
      var ht = 0;
      $('#ht-blog-section .box-panels .ht-blog-excerpt').each(function(i){
        var tHt = $(this).height();
        if(ht<tHt){
          ht=tHt;
        }
      });
      $('#ht-blog-section .box-panels .ht-blog-excerpt').height(ht+'px');
    }
    boxpanelsHeight();
  });
  $( window ).resize(function(){
    boxpanelsHeight();
  });
</script>
<?php }