<?php  
	$carpenterservice_hs_blog 			= esc_attr(get_theme_mod('hs_blog','1'));
	$carpenterservice_blog_title 		= esc_attr(get_theme_mod('blog_title'));
	$carpenterservice_blog_subtitle		= esc_attr(get_theme_mod('blog_subtitle')); 
	$carpenterservice_blog_description	= esc_attr(get_theme_mod('blog_description'));
	$carpenterservice_blog_num			= esc_attr(get_theme_mod('blog_display_num','3'));
	if($carpenterservice_hs_blog=='1'):
?>

<section id="blog-section" class="blog-area home-blog">

	<div class="<?php if(esc_attr(get_theme_mod('carpenter_service_blog_section_width','Box Width')) == 'Full Width'){ ?>container-fluid pd-0 <?php } elseif(esc_attr(get_theme_mod('carpenter_service_blog_section_width','Box Width')) == 'Box Width'){ ?> container <?php }?>">
		<div class="row ">
			<div class="header-section">
				<div class="row">
					<div class="col-md-6 pd-0">
						<h3 class="section-title"><?php echo esc_html(get_theme_mod('blog_heading')); ?></h3>
					</div>
					<div class="col-md-6 pd-0">
						<p class="section-sub"><?php echo esc_html(get_theme_mod('blog_subheading')); ?> </p> 
					</div>
				</div>
				<div class="clearfix"></div>
			</div>
		 </div> 

		<!-- <div class="row justify-content-center text-center"> -->
			<!-- <div class="header-section">
			 </?php if($blog_subheading){ ?> 
					<h5 class="section-subtitle"></?php echo esc_html(get_theme_mod('blog_subheading')); ?></h5>
					 </?php }?> 
					<h3 class="section-title"></?php echo esc_html(get_theme_mod('blog_heading')); ?>
					</h3>

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

		<?php if(!empty($carpenterservice_blog_title) || !empty($carpenterservice_blog_subtitle) || !empty($carpenterservice_blog_description)): ?>
			<div class="title">
				<?php if(!empty($carpenterservice_blog_title)): ?>
					<h6><?php echo wp_kses_post($carpenterservice_blog_title); ?></h6>
				<?php endif; ?>
				
				<?php if(!empty($carpenterservice_blog_subtitle)): ?>
					<h2><?php echo wp_kses_post($carpenterservice_blog_subtitle); ?></h2>
					<span class="shap"></span>
				<?php endif; ?>
				
				<?php if(!empty($carpenterservice_blog_description)): ?>
					<p><?php echo wp_kses_post($carpenterservice_blog_description); ?></p>
				<?php endif; ?>
			</div>
		<?php endif; ?> 


		<div class="row">
			<?php 	
				$carpenterservice_blogs_args = array( 'post_type' => 'post', 'posts_per_page' => $carpenterservice_blog_num,'post__not_in'=>get_option("sticky_posts")) ; 	
				$carpenterservice_blog_wp_query = new WP_Query($carpenterservice_blogs_args);
				if($carpenterservice_blog_wp_query)
				{	
				while($carpenterservice_blog_wp_query->have_posts()):$carpenterservice_blog_wp_query->the_post(); ?>
				<div class="col-lg-4 col-md-4 col-sm-12 ">
					<div class="blogbx">
						
							
							<?php if (has_post_thumbnail( $post->ID ) ): ?>
							<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
							<a href="<?php echo esc_url( get_permalink() ); ?>">	
								<div class="blog-image" style="background-image: url('<?php echo esc_url($image[0]); ?>')">
									<div class="admin-cat-box">
										<div id="post-<?php the_ID(); ?>" <?php post_class('blog-item'); ?>>	
											<li class="date"><?php echo get_the_date( 'j' ); ?>  </li>
											<li class="month"><?php echo get_the_date( 'M' ); ?></li>
											<!-- <li class="month"></?php echo get_the_date( 'Y' ); ?></li> -->
										</div>
									</div>

									<div class="box-admin">
										<ul class="comment-timing">
											<li><a href="<?php echo esc_url( get_permalink() ); ?>"><i class="fa fa-user"></i> By : <?php echo get_the_author() ?> </a> </li>

											<li class="comm"><a href="<?php echo esc_url( get_permalink() ); ?>"><i class="fa fa-comments"></i> <?php echo esc_html(get_comments_number($post->ID)); ?>  <?php esc_html_e('Comments','carpenter-service'); ?>  </a> </li>
										</ul>
									</div>
								</div>
							</a>
							<?php else: 
								$img = get_template_directory_uri().'/assets/images/default.png';
								?>
								<!-- <a href="<//?php echo esc_url( get_permalink() ); ?>">
									<div class="blog-image" style="background-image: url('<//?php echo esc_url($img); ?>')">
										

									</div>
								</a> -->
							<?php endif; ?>

							<div class="clearfix"></div>
							<div class="blog-content">
								
								<?php 
									if ( is_single() ) :
										
									the_title('<h6 class="post-title">', '</h6>' );
									
									else:
									
									the_title( sprintf( '<h6 class="post-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h6>' );
									
									endif; 
									?> 
									<p>
								 		<?php echo wp_trim_words(get_the_content(), 35);	?>
								 	</p>
									
									
									<div class="b-btn">
										<a href="<?php echo esc_url( get_permalink() ); ?>">
											Read more
										</a>
									</div>
							</div>
						<div class="clearfix"></div>
					</div>
				</div>

			<?php endwhile; 
				}
				wp_reset_postdata();
			?>
		</div>

	</div>

</section>
<?php endif; ?>