<?php
/**
 * Template Name: Home Page
 */

get_header();
?>

<main id="primary">

    <?php 
    $seo_specialist_main_slider_wrap = absint(get_theme_mod('seo_specialist_enable_slider', 0));
    if($seo_specialist_main_slider_wrap == 1): 
    ?>
        <section id="main-slider-wrap">
            <div class="owl-carousel">
                <?php for ($seo_specialist_main_i=1; $seo_specialist_main_i <= 3; $seo_specialist_main_i++): ?>
                    <?php if ($seo_specialist_slider_image = get_theme_mod('seo_specialist_slider_image'.$seo_specialist_main_i)): ?>
                        <div class="main-slider-inner-box">
                            <img src="<?php echo esc_url($seo_specialist_slider_image); ?>" alt="<?php echo esc_attr( get_theme_mod('seo_specialist_slider_heading'.$seo_specialist_main_i) ); ?>">
                            <div class="main-slider-content-box">
                                <div class="slide-bg wow zoomIn" data-wow-duration="1.5s">
                                    <div class="main-inner-text">
                                        <?php if ($seo_specialist_heading = get_theme_mod('seo_specialist_slider_heading' . $seo_specialist_main_i)): ?>
                                            <h1><?php echo esc_html($seo_specialist_heading); ?></h1>
                                        <?php endif; ?>

                                        <?php if ($seo_specialist_text = get_theme_mod('seo_specialist_slider_text'.$seo_specialist_main_i)): ?>
                                            <p><?php echo esc_html($seo_specialist_text); ?></p>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endif; ?>
                <?php endfor; ?>
            </div>
        </section>
    <?php endif; ?>

   <?php 
    $seo_specialist_main_expert_wrap = absint(get_theme_mod('seo_specialist_enable_event', 0));
    if($seo_specialist_main_expert_wrap == 1): 
        $seo_specialist_catData2 = get_theme_mod('seo_specialist_blog_cat','uncategorized');

        if(!empty($seo_specialist_catData2) && $seo_specialist_catData2 !== 'select'): 
            $seo_specialist_page_query = new WP_Query(array( 
                'category_name' => esc_html($seo_specialist_catData2),
                'posts_per_page' => -1  // Fetch all posts from the category
            ));

            if($seo_specialist_page_query->have_posts()): ?>
                <section id="main-expert-wrap">
                    <div class="container">
                        <div class="heading-expert-wrap">
                            <?php if ($seo_specialist_event_text = get_theme_mod('seo_specialist_event_text')): ?>
                                <h2><?php echo esc_html($seo_specialist_event_text); ?></h2>
                            <?php endif; ?>
                        </div>
                        <div id="primary">
                            <div class="owl-carousel">
                                <?php while($seo_specialist_page_query->have_posts()): $seo_specialist_page_query->the_post(); ?>
                                    <div class="box wow zoomIn" data-wow-duration="2s">
                                        <div class="box-image">
                                            <?php if (has_post_thumbnail()) { 
                                                the_post_thumbnail(); 
                                            } else { ?>
                                                <div class="no-thumbnail">
                                                </div>
                                            <?php } ?>
                                        </div>
                                        <div class="main-line">
                                            <div class="box-content">
                                                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                            </div>
                                        </div>
                                    </div>
                                <?php endwhile; wp_reset_postdata(); ?>
                            </div>
                        </div>                
                    </div>
                </section>
            <?php else: ?>
                <p><?php esc_html_e('No posts found in this category.', 'seo-specialist'); ?></p>
            <?php endif; 
        endif; 
    endif; 
    ?>
  

</main>

<?php
get_footer();
?>