<?php 
$expert_business_consultant_slider = get_theme_mod('expert_business_consultant_slider_setting', true);

if ($expert_business_consultant_slider == '1') :
?>

<section id="slider-section" class="slider-area">
  <div class="container slider-content">
    <div id="owl-carousel" class="owl-carousel owl-theme">
        <?php 
        $expert_business_consultant_pages = array();
        for ($expert_business_consultant_count = 1; $expert_business_consultant_count <= 3; $expert_business_consultant_count++) {
            $expert_business_consultant_mod = intval(get_theme_mod('expert_business_consultant_slider' . $expert_business_consultant_count));
        
            // Check that the value is valid and not the placeholder value 'page-none-selected'
            if ('page-none-selected' !== $expert_business_consultant_mod && $expert_business_consultant_mod > 0) {
                $expert_business_consultant_pages[] = $expert_business_consultant_mod;
            }
        }
        if (!empty($expert_business_consultant_pages)) :
            $args = array(
                'post_type' => 'page',
                'post__in' => $expert_business_consultant_pages,
                'orderby' => 'post__in'
            );
            $query = new WP_Query($args);
            if ($query->have_posts()) :
                while ($query->have_posts()) : $query->the_post(); ?>
                    <div class="item">
                            <div class="row">
                                <div class="col-lg-6 col-md-5 col-12 align-self-center wow fadeInRight" data-wow-delay="0.5s">
                                    <div class="carousel-caption">
                                        <div class="inner_carousel pe-lg-5">
                                            <?php
                                            $expert_business_consultant_slider_text = get_theme_mod('expert_business_consultant_slider_text');
                                            if ($expert_business_consultant_slider_text != '') { ?>
                                                <p class="mb-3 slider-top-text"><?php echo esc_html(apply_filters('expert_business_consultant_topheader', $expert_business_consultant_slider_text)); ?></p>
                                            <?php } ?>
                                            <?php
                                            $expert_business_consultant_title = get_the_title();
                                            $expert_business_consultant_title_words = explode(' ', $expert_business_consultant_title);

                                            if (count($expert_business_consultant_title_words) > 1) {
                                                $expert_business_consultant_last_two_words = array_splice($expert_business_consultant_title_words, -2, 2);
                                                $expert_business_consultant_last_two = implode(' ', $expert_business_consultant_last_two_words);
                                                $expert_business_consultant_first_part = implode(' ', $expert_business_consultant_title_words);
                                            } else {
                                                $expert_business_consultant_first_part = $expert_business_consultant_title;
                                                $expert_business_consultant_last_two = '';
                                            }
                                            ?>
                                            <h1 class="text-uppercase mb-3">
                                                <a href="<?php the_permalink(); ?>">
                                                    <?php echo esc_html($expert_business_consultant_first_part); ?> <span class="highlight"><?php echo esc_html($expert_business_consultant_last_two); ?></span>
                                                </a>
                                            </h1>
                                            <p><?php echo esc_html(wp_trim_words(get_the_content(), '28')); ?></p>
                                            <div class="read-btn mt-md-4 mt-3">
                                                <a href="<?php the_permalink(); ?>"><?php echo esc_html('Ready To Get Started', 'expert-business-consultant'); ?></a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-6 col-md-7 col-12 slider-img-col align-self-center p-0 wow fadeInLeft" data-wow-delay="0.5s">
                                    <div class="sliderimg">
                                        <?php if (has_post_thumbnail()) { ?>
                                            <img src="<?php the_post_thumbnail_url(''); ?>"/>
                                        <?php } else { ?>
                                            <div class="slider-color-box"></div>
                                        <?php } ?>
                                    </div>
                                </div>
                            </div>
                    </div>
                <?php endwhile;
                wp_reset_postdata();
            else : ?>
                <div class="no-postfound"></div>
            <?php endif;
        endif; ?>
    </div>
  </div>
</section>
<?php endif; ?>
