<?php
/**
 * Template part for displaying services section
 *
 * @package Fitness Supplement Store
 * @subpackage fitness_supplement_store
 */
?>

<?php 
$fitness_supplement_store_static_image = get_stylesheet_directory_uri() . '/assets/images/header_img.png';
if (get_theme_mod('fitness_supplement_store_featured_show_hide', true) != '') { 
?>
<section id="service-sec" class="py-5">
  <div class="container">
    <?php if (get_theme_mod('fitness_supplement_store_featured_section_tittle') != '') { ?>
      <h3 class="text-center mb-5 text-uppercase"><?php echo esc_html(get_theme_mod('fitness_supplement_store_featured_section_tittle', '')); ?></h3>
    <?php }?>
    <div class="row">
      <?php
      $fitness_supplement_store_post_category = get_theme_mod('fitness_supplement_store_serv_section_category');
      if ($fitness_supplement_store_post_category) {
        $fitness_supplement_store_page_query = new WP_Query(array('category_name' => esc_html($fitness_supplement_store_post_category)));
        if ($fitness_supplement_store_page_query->have_posts()) {
          while ($fitness_supplement_store_page_query->have_posts()) : $fitness_supplement_store_page_query->the_post(); ?>
            <div class="col-lg-4 col-md-6">
              <div class="cat-inner-box mb-4">
                <?php 
                if (has_post_thumbnail()) { 
                  the_post_thumbnail(); 
                } else {
                  echo '<img src="' . esc_url($fitness_supplement_store_static_image) . '" alt="Default Image">';
                } 
                ?>
                <div class="inner-content text-center">
                  <h4 class="mt-3 mb-0 mx-4"><a href="<?php the_permalink(); ?>" class="text-uppercase"><?php the_title(); ?></a></h4>
                  <p><?php echo esc_html(wp_trim_words(get_the_content(), 3)); ?></p>
                </div>
              </div>
            </div>
          <?php endwhile;
          wp_reset_postdata();
        } else { ?>
            <div class="no-postfound"><p><?php echo esc_html__('No posts found', 'fitness-supplement-store'); ?></p></div>
      <?php
        }
      }
      ?>
    </div>
  </div>
</section>
<?php } ?>
