<?php
/**
 *
 * @package LZ Restaurant Premium
 */

if(get_theme_mod('blog_section_disable') != 'on' ){
	?>

<?php 
            if( get_theme_mod('sectionblog_toppadding',true) ) {
                $sectionblog_toppadding = 'padding-top:'.esc_attr(get_theme_mod('sectionblog_toppadding')).';';
            }
            if( get_theme_mod('sectionblog_bottompadding',true) ) {
                $sectionblog_bottompadding = 'padding-bottom:'.esc_attr(get_theme_mod('sectionblog_bottompadding')).';';
            }
            if( get_theme_mod('sectionblog_leftpadding',true) ) {
                $sectionblog_leftpadding = 'padding-left:'.esc_attr(get_theme_mod('sectionblog_leftpadding')).';';
            }
            if( get_theme_mod('sectionblog_rightpadding',true) ) {
                $sectionblog_rightpadding = 'padding-right:'.esc_attr(get_theme_mod('sectionblog_rightpadding')).';';
            }
    ?>   

	<section id="ht-blog-section" class="ht-section" style="<?php echo esc_attr($sectionblog_toppadding); ?>" "<?php echo esc_attr($sectionblog_bottompadding); ?>" "<?php echo esc_attr($sectionblog_leftpadding); ?>" "<?php echo esc_attr($sectionblog_rightpadding); ?>" >
			<div class="container">
				<div class=" wow fadeInUp" data-wow-duration="1s">
					<?php
					$lz_fitness_aboutus_page_id = get_theme_mod('lz_fitness_blog_page');
					$lz_fitness_blog_sub_title = get_theme_mod('lz_fitness_blog_sub_title', 'Here goes the short description for the section');
					$lz_fitness_blog_title = get_theme_mod('lz_fitness_blog_title', 'Blog Section');		
					?>
					<?php if($lz_fitness_blog_title || $lz_fitness_blog_sub_title){ ?>
					<div class="row">
						<div class="ht-section-title-tagline">
							<?php if($lz_fitness_blog_sub_title){ ?>
							<div class="ht-section-tagline lz-blog-text"><?php echo esc_html($lz_fitness_blog_sub_title); ?></div>
							<?php } ?>

							<?php if($lz_fitness_blog_title){ ?>
							<h2 class="ht-section-title lz-blog-heading"><?php echo esc_html($lz_fitness_blog_title); ?></h2>
							<?php } ?>
						</div>
						<?php } ?>

						<div class="ht-blog-wrap">
							<div class="ht-blog-post">
								<?php 
								$lz_fitness_blog_post_count = get_theme_mod('lz_fitness_blog_post_count', 2 );
								$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/about.jpg';
										}
										?>
										<div class="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">
												 <div class="col-md-2 text-center padding0">
													 <div class="ht-blog-date">
													 <?php echo get_the_date( 'j <br/><b>M</b>' ); ?><?php //echo get_the_date( 'm-d-Y' ); ?>
													 </div>
													 <div class="ht-blog-comment">
													 	
													<i class="fa fa-comment" aria-hidden="true"></i> <?php echo $my_var = get_comments_number(); ?> 
													</div>
												 </div>
												  <div class="col-md-10 post-right">
												   <span>Post By <b><?php echo get_the_author(); ?></b>  |  <?php foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } ?> </span>
													<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() , 100 );
														}
														?>
													</p>
													<?php if( get_theme_mod('blog_button_display','show' ) == 'show') :
											?>
											<?php
												$blog_page_id = get_theme_mod('blog_page'); 
												$blogbutn_text = get_theme_mod('blogbutn_text', 'Read More');
												?>

											<div class="blog-read-more">
												<a href="<?php the_permalink(); ?>"><?php echo $blogbutn_text; ?></a>
											</div>
											<?php endif ?>


													</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>
	</section>
<?php
}