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

if(get_theme_mod('lz_fitness_blog_section_disable') != 'on' ){ ?>
	<section id="ht-blog-box">
		<div class="lightbox">
			<div class="container">
				<?php if( get_theme_mod('blogmainsecanimation_button_display','show' ) == 'show') :
					?>	
					<div class="hex center">
						<div class="hex odd first one"></div>
						<div class="hex odd first three"></div>
						<div class="hex odd first five"></div>
						<div class="hex odd first seven"></div>
						<div class="hex odd first nine"></div>
						<div class="hex odd first eleven"></div>

					</div>
				<?php endif ?>
				
				<?php
				$lz_fitness_blog_title = get_theme_mod('lz_fitness_blog_title', 'Blog Section');
				$lz_fitness_blog_sub_title = get_theme_mod('lz_fitness_blog_sub_title', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus eu pharetra ex. Etiam eget diam ligula. Sed at blandit ante.');
				?>
				<div class="ht-section-title-tagline">
					<?php if($lz_fitness_blog_title || $lz_fitness_blog_title){ ?>
						<h2 class="ht-section-title lz-blog-heading">
							<?php
							if(!empty($lz_fitness_blog_title))	{
								echo ($lz_fitness_blog_title);
							} ?>
						</h2>
					<?php }?>
					<div class="clearfix"></div> 
					<div class="col-md-6 col-md-offset-3 lz-blog-subheading">
						<?php
						if(!empty($lz_fitness_blog_sub_title))	{
							echo ($lz_fitness_blog_sub_title);
						} ?>
					</div> 
					<div class="clearfix"></div>
				</div>
				<div class="clearfix"></div>

				
				<div class="ut-blog-post">
					<div class="ut-blog-posts-box">
						<div class="bloghomebox">
							<?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/nothumb-featured.png';
									}
									?>
									<div class="col-md-4 col-sm-6 padding18 wow pulse" data-wow-duration="4s">
										
										<div class="mainbloghpage">
											<figure class="homepage-blog-img blue">
												<img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>">

												<i class="fa fa-calendar"></i>
												<a href="<?php the_permalink(); ?>"></a>
											</figure>
											<div class="detailblogbox">
												<ul>
													<li><i class="fa fa-calendar"></i><?php echo get_the_date( 'j-m-Y' ); ?></li> 
													<li> 
														<i class="fa fa-comment"></i>Comments (<?php echo $my_var = get_comments_number(); ?>) 
													</li>
												</ul>	
												<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>

												<div class="ht-blog-excerpt">
													<?php 
													if(has_excerpt()){
														echo get_the_excerpt();
													}else{
														echo lz_fitness_excerpt( get_the_content() , 110 );
													}
													?>
													<!-- <a href="<?php // the_permalink(); ?>"><?php // _e('Read More', 'total'); ?></a> -->
												</div>
											</div>
										</div>
									</a>
								</div>

								<?php
							endwhile;
						endif;
						wp_reset_postdata();
						?>
					</div>
				</div>
				<div class="clearfix"></div>
			</div>	
			<?php
			$homepageblogbtnsectionbutton = get_theme_mod('lz_fitness_homepageblogbtnsection_txt', 'View More'); 
			$homepageblogbtnectionlink = get_theme_mod('lz_fitness_homepageblogbtnectionlink', 'add link here');
			?>

			<?php if( get_theme_mod('homepageblogbtnection_button_display','show' ) == 'show') :
				?>	
				<div class="text-center">
					<a href="<?php echo $homepageblogbtnectionlink ?>" target="_blank" class="btn btn-lg red">			
						<?php echo ($homepageblogbtnsectionbutton );  ?>
					</a></div>
				<?php endif ?>
			</div>
		</div>
		<?php if( get_theme_mod('blogsectionsjape_button_display','show' ) == 'show') :
			?>	
			<div class="blogshape"></div> 
		<?php endif ?>

	</section>

	<script>
		jQuery.noConflict();
		$(function(){
			function detailblogboxHeight(){
				var ht = 0;
				$('section#ht-blog-box .detailblogbox').each(function(i){
					var tHt = $(this).height();
					if(ht<tHt){
						ht=tHt;
					}
				});
				$('section#ht-blog-box .detailblogbox').height(ht+'px');
			}
			detailblogboxHeight();
		});
		$( window ).resize(function(){
			detailblogboxHeight();
		});
	</script>
<?php }