<?php
/**
 * Template part for displaying projects section
 *
 * @package Painting Contractor
 * @subpackage painting_contractor
 */
?>
<?php $painting_contractor_static_image= get_template_directory_uri() . '/assets/images/header_img.png'; ?>

<?php if( get_theme_mod( 'painting_contractor_project_show_hide', true) != '') { ?>
<section id="projetcs-sec" class="py-5">
  <div class="container">
    <div class="row mb-4">
      <div class="col-lg-4 col-md-4 col-sm-4 align-self-center">
        <div class="title-head">
          <?php if( get_theme_mod('painting_contractor_projetcs_main_text') != '' ){ ?>
            <p><?php echo esc_html(get_theme_mod('painting_contractor_projetcs_main_text',''));?></p>
          <?php }?>
          <?php if( get_theme_mod('painting_contractor_projetcs_main_heading') != '' ){ ?>
            <h2><?php echo esc_html(get_theme_mod('painting_contractor_projetcs_main_heading',''));?></h2>
          <?php }?>
        </div>
      </div>
      <div class="col-lg-8 col-md-8 col-sm-8 align-self-center text-center text-md-end">
        <div class="more-btn">
          <?php if( get_theme_mod('painting_contractor_projetcs_btn_url') != '' || get_theme_mod('painting_contractor_projetcs_btn_text') != '' ){ ?>
            <a href="<?php echo esc_url(get_theme_mod('painting_contractor_projetcs_btn_url',''));?>"><?php echo esc_html(get_theme_mod('painting_contractor_projetcs_btn_text',''));?></a>
          <?php }?>
        </div>
      </div>
    </div>
    <div class="row">
      <?php
      $painting_contractor_catData = get_theme_mod('painting_contractor_projetcs_category','');
      if($painting_contractor_catData){
        $painting_contractor_page_query = new WP_Query(array( 'category_name' => esc_html( $painting_contractor_catData ,'painting-contractor')));
        $bgcolor = 1; ?>
        <?php while( $painting_contractor_page_query->have_posts() ) : $painting_contractor_page_query->the_post(); ?>
          <div class="col-lg-3 col-md-6">
              <div class="box mb-4">
                <?php if(has_post_thumbnail()) {?>
                <?php the_post_thumbnail(); }else {echo ('<img src="'.$painting_contractor_static_image.'">'); } ?>
                <div class="box-content">
                  <h3 class="title"><a href="<?php the_permalink();?>"><?php the_title();?><span class="screen-reader-text"><?php the_title(); ?></span></a></h3>
                  <p><?php echo wp_trim_words( get_the_content(),8 );?></p>
                </div>
              </div>
          </div>
        <?php endwhile;
        wp_reset_postdata();
      } ?>
    </div>
  </div>
</section>
<?php }?>
