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

if(get_theme_mod('lz_fitness_blog_section_disable') != 'on' ){ ?>
	<section id="ht-blog-section" class="ht-section">
		<div class="lightbox">
			<div class="container">
				<div class=" wow fadeInUp" data-wow-duration="1s">
					<?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', 'Here goes the short description for the 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_title){ ?>
									<h2 class="ht-section-title lz-blog-heading"><?php echo esc_html($lz_fitness_blog_title); ?></h2>
								<?php } ?>

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

						<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/about.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">
												<div class="col-md-2 text-center padding0">
													<div class="ht-blog-date"><?php echo get_the_date( 'j <br/><b>M</b>' ); ?>
												</div>
                                                     <div class="ht-blog-comment">
													 	
													<i class="fa fa-comment" aria-hidden="true"></i> <br>
													<?php //echo $my_var = get_comments_number( $post_id ); ?> 
													<?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() , 190 );
														}
														?>
													</p>
													<div class="blog-read-more">
														<a href="<?php the_permalink(); ?>"><?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>
				</section>
			<?php }