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

if(get_theme_mod('blog_area_disable') != 'on' ){ ?>
	<?php 
 	if( get_theme_mod('blog_areaTpadding',true) ) {
 		$blog_areaTpadding = 'padding-top:'.esc_attr(get_theme_mod('blog_areaTpadding')).';';
 	}
 	if( get_theme_mod('blog_areaBpadding',true) ) {
 		$blog_areaBpadding = 'padding-bottom:'.esc_attr(get_theme_mod('blog_areaBpadding')).';';
 	}
 
 	?>
<div  class="blog-area" id="blog" style="<?php echo esc_attr($blog_areaTpadding); ?>" "<?php echo esc_attr($blog_areaBpadding); ?>">
 		
			<?php
				$showStatic = true;
				for( $i = 2; $i < 3; $i++ ){
					$luzuk_blog_page_id = get_theme_mod('luzuk_blog_page'.$i); 
					if(!empty($luzuk_blog_page_id)){
						$showStatic = false;
						break;
					}
				}
				

 		$blog_title = get_theme_mod('blog_title_title', 'LATTEST NEWS');
 		?>

		<div class="container">
			<div class=" wow zoomIn" data-wow-duration="1s">
				
						<div class="row">
							<div class="section-title pd-0">
								<h2><?php echo ($blog_title);?></h2>
							</div>
						</div>
						<div class="s-border">
						<div class="ht-blog-wrap">
							<div class="ht-blog-post">
									<div class="owl-carousel owl-theme">    
										<?php 
										$luzuk_blog_post_count = get_theme_mod('luzuk_blog_post_count', 12 );
										$luzuk_blog_cat_exclude = get_theme_mod('luzuk_blog_cat_exclude');
										$luzuk_blog_cat_exclude = explode(',', $luzuk_blog_cat_exclude);
										$args = array(
											'posts_per_page' => absint($luzuk_blog_post_count),
											'category__not_in' => $luzuk_blog_cat_exclude
										);

										// $item = 0;

										$query = new WP_Query($args);
										if($query -> have_posts()):
											while($query -> have_posts()) : $query -> the_post();
												// $item++;
												$luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id() , 'total-blog-thumb');
												if(has_post_thumbnail()){
													$img = esc_url($luzuk_image[0]);
												}
												if(empty($luzuk_image)){
													$img = get_template_directory_uri().'/images/blog-default.jpg';
												}
												?>
												<div class="item">
													<div class="box-area-S">
														<div class="blog-thumbnail">
															<a href="<?php the_permalink(); ?>"><img class="blog-img" src="<?php echo $img; ?>" alt="<?php the_title(); ?>"></a>
															<ul class="icon">
									                            <li><a href="<?php the_permalink(); ?>"><i class="fa fa-link"></i></a></li>
									                        </ul>
														<div class="boverlay"></div>
														<div class="blog-category">
															<?php the_category(','); ?>
							                            </div>
														</div>
														<div class="blog-single">
														<a href="<?php the_permalink(); ?>"><h4 class="inner-area-title"><?php the_title(); ?></h4></a>
														<div class="blog-date">
															<?php echo get_the_date( 'j F Y' ); ?>
														</div>
														<div class="clearfix"></div>
														</div>
														<div class="clearfix"></div>
													</div>	
												</div>						
												<?php
											endwhile;
										endif;
										wp_reset_postdata();
										?>
									</div>
									</div>
						</div>
					</div>
					</div>
				</div>
				<div class="clearfix"></div>
			</div>
		</section>
		<script>
			$(document).ready(function() {
				$('.blog-area .owl-carousel').owlCarousel({
					loop: true,
					margin: 30,
					responsiveClass: true,
					responsive: {
						0: {
							items: 1,
							nav: true
						},
						600: {
							items:2,
							nav: true
						},
						1000: {
							items:3,
							nav: true,
							loop: false,
							margin: 35
						}
					}
				})
			})
		</script>
		<?php }