/home/bdqbpbxa/demo-subdomains/homesearch.goodface.com.ua/wp-content/themes/homesearch/webinars.php
<?php

 // Template name: Webinars

  get_header();

  $srcset = get_template_directory_uri() . "/assets/images/lazyload.png";
?>

<main>
  <?php  
    get_template_part('templates/inner-page-main');
  ?>


  <?php
    $webinars_list = new WP_query([
      'post_type' => 'webinars',
      'post_per_page' => -1,
      'numberposts' => -1,
      ]);

      $feature_post_id = [];
      $past_post_id = [];
    foreach($webinars_list->posts as $post) {
      $main = get_field('main-container', $post->ID);
      date_default_timezone_set('Europe/London');
      $webinars_date = $main['webinars_time']['webinars_date'];      
      $webinars_date_time_ends = $main['webinars_time']['webinars_ends'];                  
      $current_date = date('l jS F Y,g:ia');

      if (strtotime($current_date) <= strtotime($webinars_date)) {        
        array_push($feature_post_id, $post->ID);
      } else {
        array_push($past_post_id, $post->ID);
      }
    }
    wp_reset_postdata();
    

    $feature_webinars = new WP_query([
      'post_type' => 'webinars',
      'post_per_page' => -1,
      'numberposts' => -1,
      'post__in' => $feature_post_id,
      ]);

    $previous_webinars = new WP_query([
      'post_type' => 'webinars',
      'post_per_page' => -1,
      'numberposts' => -1,
      'post__in' => $past_post_id,
      ]);

    $upcoming_sessions = get_field('upcoming_sessions');

    if ($upcoming_sessions['title'] && $feature_webinars->have_posts() && count($feature_post_id) != 0) :
  ?>
    <section class="upcoming-section <?php echo get_section_color($upcoming_sessions['block_color']); ?>">
      <div class="container -smaller">
        <h2 class="title title-2 mob-title-2 -centered-title"><?php echo $upcoming_sessions['title']; ?></h2>
        <div class="info-card-list -max-width-1120">
          <?php
            foreach($feature_webinars->posts as $webinar) {
              $args = [];
              $args['obj'] = $webinar;
              $args['card_class'] = '-bigger -without-img';
              get_template_part('templates/cards/webinar-card', null, $args);
            }
          ?>
        </div>
      </div>
    </section>
  <?php
    endif;
    

    $previous_sessions = get_field('previous_sessions');
    if ($previous_sessions['title'] && $previous_webinars->have_posts()) :
  ?>
    <section class="previous-section <?php echo get_section_color($previous_sessions['block_color']); ?>">
      <div class="container -smaller">
        <h2 class="title-2 mob-title-2 -centered-title"><?php echo $previous_sessions['title']; ?></h2>
        <div class="info-card-list -max-width-1120">
          <?php
            foreach($previous_webinars->posts as $webinar) {
              $args = [];
              $args['obj'] = $webinar;
              $args['card_class'] = '-without-img';
              $args['link_class'] = '--play-link';
              get_template_part('templates/cards/webinar-card', null, $args);
            }
          ?>
        </div>
      </div>
    </section>
  <?php
    endif;
  ?>

  <?php
    $why_you_should_attend = get_field('why_you_should_attend');

    if ($why_you_should_attend['title'] && $why_you_should_attend['benefits_list']) :
  ?>
    <section class="solving-section <?php echo get_section_color($why_you_should_attend['block_color']); ?>">
      <div class="container -smaller">
        <h2 class="title -centered-title title-2 mob-title-2"><?php echo $why_you_should_attend['title']; ?></h2>
        <?php
          $args = [];
          $args['obj'] = $why_you_should_attend['benefits_list'];
          $args['title_class'] = 'title-5 mob-text-1';
          get_template_part('templates/components/solving-list', null, $args);
        ?>
      </div>
    </section>
  <?php
    endif;
  ?>

  <?php
    get_template_part('templates/testimonials-section');

    $args = [];
    $args['obj'] = get_field('call_to_action')['call_to_action'];
    get_template_part('templates/small-info-section', null, $args);
  ?>
</main>

<?php
  get_footer();
?>