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

if(get_theme_mod('lz_fitness_blog_section_disable') != 'on' ){ ?>
	<section id="ht-blog-section" class="ht-section">
		<?php if( get_theme_mod('cds_blog_curvedisplay','show' ) == 'show') :
			?>
		<div class="blogwavecurve">
	        <svg class="header-separator-svg header-separator-svg__waves_svg_separator" xmlns="http://www.w3.org/2000/svg" version="1.0" width="1200" fill="#f1f2f4" height="30" viewBox="0 0 1200 30" preserveAspectRatio="none"><path d="M0,0S1.209,1.508,200.671,7.031C375.088,15.751,454.658,30,600,30V0H0ZM1200,0s-90.21,1.511-200.671,7.034C824.911,15.751,745.342,30,600,30V0h600Z"></path></svg>
		</div>
    <?php endif ?>
		<div class="container">
			<div class=" wow fadeInUp" data-wow-duration="1s">
				<?php
				$lz_fitness_blog_title = get_theme_mod('lz_fitness_blog_title', 'Latest Post');
				?>
				<?php if($lz_fitness_blog_title){ ?>
					<div class="row">
						<div class="ht-section-title-tagline">
							<?php if($lz_fitness_blog_title){ ?>
								<h2 class="ht-section-title lz-blog-heading"><?php echo ($lz_fitness_blog_title); ?></h2>
							<?php } ?>
							<div class="dlab-separator-outer m-b0">
								<div class="dlab-separator text-primary style-icon"><i class="fa fa-birthday-cake"></i></div>
							</div>
						</div>
						
					<?php } ?>
					<div class="clearfix"></div>
					</div>
					<div class="row">
					<div class="ht-blog-wrap">
						<div class="ht-blog-posts">

						<?php 
						$lz_fitness_blog_post_count = get_theme_mod('lz_fitness_blog_post_count', 3 );
						$lz_fitness_blog_cat_exclude = get_theme_mod('lz_fitness_blog_cat_exclude');
						$lz_fitness_blog_cat_exclude = explode(',', $lz_fitness_blog_cat_exclude);
						$args = array(
							'posts_per_page' => absint($lz_fitness_blog_post_count),
							'category__not_in' => $lz_fitness_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/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="ht-blog-excerpt">
											<?php if( get_theme_mod('cds_singleblog_curvedisplay','show' ) == 'show') :
													?>
												<div class="blogboxwavecurve">
											        <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
													     viewBox="0 0 1400 90" style="enable-background:new 0 0 1440 126;" xml:space="preserve">
													<style type="text/css">
													    .st0{fill:#0052CC;}
													</style>
													<title>Rectangle 3</title>
													<desc>Created with Sketch.</desc>
													<path class="st0" d="M685.6,38.8C418.7-11.1,170.2,9.9,0,30v96h1440V30C1252.7,52.2,1010,99.4,685.6,38.8z"/>
													</svg>
												</div>
										    <?php endif ?>
											<div class="blog-date"><?php echo get_the_date( 'j F Y' ); ?></div>
											<div class="blogborder"></div> 
											<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
												<p>
													<?php 
													if(has_excerpt()){
														echo get_the_excerpt();
													}else{
														echo lz_fitness_excerpt( get_the_content() , 200 );
													}
													?>
												</p>
												<div class="blogbtn">
													 <div class="blog-read-more">
														<a href="<?php the_permalink(); ?>" target="_blank"><?php _e('Read More', 'total'); ?></a>
													</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').each(function(i){
        var tHt = $(this).height();
        if(ht<tHt){
          ht=tHt;
        }
      });
      $('#ht-blog-section .box-panels').height(ht+'px');
    }
    boxpanelsHeight();
  });
  $( window ).resize(function(){
    boxpanelsHeight();
  });
</script>
<?php }