<?php 
/**
 * Template part for displaying Featured Classes Section
 *
 * @package SEO Consultant
 */

$seo_consultant_classes = get_theme_mod( 'seo_consultant_classes_setting', false );
$seo_consultant_service_title = get_theme_mod( 'seo_consultant_service_title' );
$seo_consultant_service_text = get_theme_mod( 'seo_consultant_service_text' );

?>
<?php if ( $seo_consultant_classes ) { ?>
<div class="our-classes">
    <div class="container">
        <div class="service">
            <div class="sec-head">
                <?php if ( $seo_consultant_service_text ) { ?>
                    <p class="title-text"><?php echo esc_html( $seo_consultant_service_text ); ?></p>
                <?php } ?> 
                <?php if ( $seo_consultant_service_title ) { ?>
                    <h3 class="mb-5"><?php echo esc_html( $seo_consultant_service_title ); ?></h3>
                <?php } ?>                       
            </div>
            <div class="owl-carousel">
                <?php 
                $seo_consultant_catergory_name = get_theme_mod('seo_consultant_blog_args_');
                $args = array(
                    'post_type'           => 'post',
                    'category_name'       => $seo_consultant_catergory_name,
                    'orderby'             => 'post__in',
                    'ignore_sticky_posts' => true,
                );

                $loop = new WP_Query($args);
                if ( $loop->have_posts() ) :
                    $seo_consultant_serial_number = 1;
                    while ( $loop->have_posts() ) : $loop->the_post(); 
                        $seo_consultant_formatted_serial = sprintf("%02d", $seo_consultant_serial_number);
                        ?>
                        <div class="align-self-center px-0">
                            <div class="box my-3 wow zoomInUp delay-1000" data-wow-duration="2s">
                                <?php if ( has_post_thumbnail() ) : ?>
                                    <div class="image-blog">
                                        <?php the_post_thumbnail(); ?>
                                        <div class="serial-number">
                                            <?php echo esc_html( $seo_consultant_formatted_serial ); ?>
                                        </div>
                                    </div>
                                <?php else : ?>
                                    <div class="image-blog">
                                        <img src="<?php echo get_stylesheet_directory_uri() . '/images/default-header.png'; ?>">
                                        <div class="serial-number">
                                            <?php echo esc_html( $seo_consultant_formatted_serial ); ?>
                                        </div>
                                    </div>
                                <?php endif; ?>
                                
                                <div class="box-content">
                                    <h4 class="title mb-2">
                                        <?php the_title(); ?>
                                    </h4>
                                    <p class="mb-0"><?php echo wp_trim_words( get_the_content(), 8 ); ?></p>
                                    <p class="blog-btn mt-3">
                                        <a href="<?php echo esc_url(get_permalink($post->ID)); ?>">
                                            <?php esc_html_e('View Service', 'seo-consultant'); ?>
                                        </a>
                                    </p>
                                </div>
                            </div>
                        </div>
                    <?php  
                    $seo_consultant_serial_number++;
                    endwhile;
                endif;
                ?>
            </div>
        </div>
    </div>
</div>
<?php } ?>
