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

if(get_theme_mod('lz_fitness_blog_section_disable') != 'on' ){ ?>
	<section id="ht-blog-box">
		<?php 
		if( get_theme_mod('sec_blogsectionTpadding',true) ) {
			$sec_blogsectionTpadding = 'padding-top:'.esc_attr(get_theme_mod('sec_blogsectionTpadding')).';';
		}
		if( get_theme_mod('sec_blogsectionBpadding',true) ) {
			$sec_blogsectionBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('sec_blogsectionBpadding')).';';
		}
		if( get_theme_mod('sec_blogsectionLpadding',true) ) {
			$sec_blogsectionLpadding = 'padding-left:'.esc_attr(get_theme_mod('sec_blogsectionLpadding')).';';
		}
		if( get_theme_mod('sec_blogsectionRpadding',true) ) {
			$sec_blogsectionRpadding = 'padding-right:'.esc_attr(get_theme_mod('sec_blogsectionRpadding')).';';
		}
		?>	
		<div class="lightbox" style="<?php echo esc_attr($sec_blogsectionTpadding); ?>" "<?php echo esc_attr($sec_blogsectionBpadding); ?>" "<?php echo esc_attr($sec_blogsectionLpadding); ?>" "<?php echo esc_attr($sec_blogsectionRpadding); ?>">
			<div class="container">
				
				<?php
				$lz_fitness_blog_title = get_theme_mod('lz_fitness_blog_title', 'Latest New & Articles');
				$lz_fitness_blog_sub_title = get_theme_mod('lz_fitness_blog_sub_title', 'Our Blog & News');
				?>


				<div class="ht-section-title-tagline">
					<?php if( get_theme_mod('blogstitlebgimage_display','show' ) == 'show') :
						?>	
						<?php 
						if( get_theme_mod('sec_blogtitleimage',true) ) {
							$sec_blogtitleimage = 'top:'.esc_attr(get_theme_mod('sec_blogtitleimage')).';';
						}

						?>	

						<div class="title-image" style="<?php echo esc_attr($sec_blogtitleimage); ?>">  

							<?php 
							$lz_fitness_blogsttl_image = get_theme_mod('lz_fitness_blogsttl_image');
							if(!empty($lz_fitness_blogsttl_image)){
								echo '<img alt="'. esc_html(get_the_title()) .'" src="'.esc_url($lz_fitness_blogsttl_image).'" class="img-responsive" />';
							}else{
								echo '<img alt="blogs Title Image" src="'.get_template_directory_uri().'/images/articlalbg.png" class="img-responsive aboutbox-img" />';
							}
							?>
						</div>
					<?php endif ?>
					<?php if($lz_fitness_blog_title || $lz_fitness_blog_title){ ?>
						<div class="lz-blog-subheading">
							<?php
							if(!empty($lz_fitness_blog_sub_title))	{
								echo ($lz_fitness_blog_sub_title);
							} ?>
						</div> 
						<div class="clearfix"></div>
						<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>
				<div class="clearfix"></div>

				<?php 
		if( get_theme_mod('sec_blogsectionboxTpadding',true) ) {
			$sec_blogsectionboxTpadding = 'padding-top:'.esc_attr(get_theme_mod('sec_blogsectionboxTpadding')).';';
		}
		if( get_theme_mod('sec_blogsectionboxBpadding',true) ) {
			$sec_blogsectionboxBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('sec_blogsectionboxBpadding')).';';
		}
		if( get_theme_mod('sec_blogsectionboxLpadding',true) ) {
			$sec_blogsectionboxLpadding = 'padding-left:'.esc_attr(get_theme_mod('sec_blogsectionboxLpadding')).';';
		}
		if( get_theme_mod('sec_blogsectionboxRpadding',true) ) {
			$sec_blogsectionboxRpadding = 'padding-right:'.esc_attr(get_theme_mod('sec_blogsectionboxRpadding')).';';
		}
		?>	
				<div class="ut-blog-post" style="<?php echo esc_attr($sec_blogsectionboxTpadding); ?>" "<?php echo esc_attr($sec_blogsectionboxBpadding); ?>" "<?php echo esc_attr($sec_blogsectionboxLpadding); ?>" "<?php echo esc_attr($sec_blogsectionboxRpadding); ?>"> 
					

					<?php 
					$lz_fitness_blog_post_count = get_theme_mod('lz_fitness_blog_post_count', 5 );
					$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">
								<div class="our-homepage-blog wow zoomIn">
									<a href="<?php the_permalink(); ?>">
										<div class="pc_blog_img">
											<img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>">
											<ul class="social text-center">
												<li><?php echo get_the_date( 'j' ); ?><br>
													<?php echo get_the_date( 'M' ); ?>
												</li>

											</ul>
										</div>
									</a>
									<div class="pc_blog_content pc-blog-content">
										<ul>
											<li><?php echo get_the_author(); ?></li>
											<li><?php echo $my_var = get_comments_number(); ?> Comments</li>
										</ul>
										<h3 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
										<p class="post"><?php 
										if(has_excerpt()){
											echo get_the_excerpt();
										}else{
											echo lz_fitness_excerpt( get_the_content() , 100 );
										}
										?></p>
										<?php
										$homepageblogbtnsectionbutton = get_theme_mod('lz_fitness_homepageblogpostbtnsection_txt', 'READ MORE'); 
										?>
										<?php if( get_theme_mod('homepageblogpostbtnection_button_display','show' ) == 'show') :
											?>	
											<a href="<?php the_permalink(); ?>" class="site-button"><?php echo ($homepageblogbtnsectionbutton );  ?></a>
										<?php endif ?>
									</div>
								</div>
							</div>
							<?php
						endwhile;
					endif;
					wp_reset_postdata(); 
					?>

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

			</div>
		</div>

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

<?php }