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

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

<div  class="blog-area" id="blog" >
		
	<?php			
		$blog_subtitle = get_theme_mod('blog_subtitle', 'Blog Post');
		$blog_title = get_theme_mod('blog_title', 'Lorem Ipsum Are Believable.');
	?>

		<div class="" data-wow-duration="1s">
				<div class="container">
						<div class="section-title-area">
		            <div class="section-title">
		                <h4><?php echo ($blog_subtitle); ?></h4>
		                <h2><?php echo ($blog_title); ?></h2>              
		            </div>
		            <div class="clearfix"></div>  
		        </div>
						<div class="row">
								<div class="blog-area-wrap">
										<div class="blog-posts">
												<?php 
    $blog_post_count = get_theme_mod('blog_post_count', 3);
    $blog_cat_exclude = get_theme_mod('blog_cat_exclude');
    $blog_cat_exclude = explode(',', $blog_cat_exclude);
    $args = array(
        'posts_per_page' => absint($blog_post_count),
        'category__not_in' => $blog_cat_exclude
    );
    $query = new WP_Query($args);

    $i = 1; // ✅ Initialize the post counter here

    if($query->have_posts()):
        while($query->have_posts()) : $query->the_post();

            $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.jpg';
            }
?>
												<div class="blog-post col-md-4 col-sm-6 col-xs-12">
														<div class="box-area-S">
																<div class="blog-imgbox">
																		<div class="blog-date">
																				<ul>
																						<li class="dte"><?php echo $i; ?> </li>  
																						<li > <?php echo get_the_date( 'j' ); ?></li>       
																		        <!-- <li></?php echo get_the_date( 'Y' ); ?></li> -->
																		        <li ><?php echo get_the_date( 'M' ); ?></li>
																	      </ul>
																		</div>
																		<div class="blog-img">
																				<a href="<?php the_permalink(); ?>" class="blog-thumbnail">	
																					<img  src="<?php echo $img; ?>" alt="<?php the_title(); ?>"> 
																				</a>
																				<div class="clearfix"></div>
																		</div>
																</div>
																<div class="blog-single">
																		<a href="<?php the_permalink(); ?>"><h4 class="inner-area-title"><?php the_title(); ?></h4></a>
																				<div class="section-area-text">
																				<?php 
																						if(has_excerpt()){
																							echo get_the_excerpt();
																						}else{
																							echo luzuk_excerpt( get_the_content() , 80 );
																						}
																					?>
																				</div>
																		<?php
						                            $blogbutton1 = get_theme_mod('homepageblog_txt1', 'More Posts'); 
						                          ?>
						                             
						                          <?php if($blogbutton1){ ?>
						                              <div class="readmore1">
						                                  <a href="<?php echo esc_url(get_permalink()); ?>" class="more-button"><?php echo ($blogbutton1 );  ?>
						                                  </a>
						                              </div>
						                          <?php }?>
																		
																		<div class="clearfix"></div>
																</div>
														</div>
												</div>
												<?php
        										$i++; // ✅ Increment the counter after each post
												        endwhile;
												    endif;
												    wp_reset_postdata();
												?>
										</div>
										<div class="clearfix"></div>
								</div>	
								<div class="clearfix"></div>
						</div>
				</div>
		</div>
		<div class="clearfix"></div>
</div>

<?php }