<?php
/**
 * Template part for displaying product section
 *
 * @package Author Writer
 * @subpackage author_writer
 */
?>

<?php if( get_theme_mod( 'author_writer_product_show_hide',true) != '') { ?>
<section id="product" class="my-5">
  <div class="container">
      <?php
      $author_writer_featured_car_section_short_title = get_theme_mod('author_writer_featured_car_section_short_title', '');
      if (!empty($author_writer_featured_car_section_short_title)) : ?>
        <h2 class="text-uppercase text-center"><?php echo esc_html($author_writer_featured_car_section_short_title); ?></h2>
      <?php endif; ?>
    <div class="row">
      <?php $author_writer_bestseller_product_pages = array();
            for ( $author_writer_count = 0; $author_writer_count <= 4; $author_writer_count++ ) {
              $mod = absint( get_theme_mod( 'author_writer_bestseller_product_page' ));
              if ( 'page-none-selected' != $mod ) {
                $author_writer_bestseller_product_pages[] = $mod;
              }
            }
            if( !empty($author_writer_bestseller_product_pages) ) :
              $args = array(
                'post_type' => 'page',
                'post__in' => $author_writer_bestseller_product_pages,
                'orderby' => 'post__in'
              );
              $query = new WP_Query( $args );
              if ( $query->have_posts() ) :
                $author_writer_count = 0;
                while ( $query->have_posts() ) : $query->the_post(); ?>
                  <?php the_content(); ?>
                <?php $author_writer_count++; endwhile; ?>
              <?php else : ?>
                  <div class="no-postfound"></div>
              <?php endif;
            endif;
            wp_reset_postdata();
          ?>
    </div>
  </div>
</section>
<?php }?>