<?php 
/**
 * Template part for displaying Featured Classes Section
 *
 * @package Psychologist Counselor
 */

$psychologist_counselor_classes = get_theme_mod( 'psychologist_counselor_classes_setting',false );
$psychologist_counselor_service_title = get_theme_mod( 'psychologist_counselor_service_title' );

?>
<?php if ( $psychologist_counselor_classes ){?>
<div class="our-classes">
    <div class="container">
        <div class="service">
            <div class="side-border">
                <?php if ( $psychologist_counselor_service_title ){?>
                    <h3 class="mb-4"><?php echo esc_html( $psychologist_counselor_service_title );?></h3>
                <?php } ?>                      
            </div>
            <div class="owl-carousel">
                <?php 
                    $psychologist_counselor_catergory_name = get_theme_mod('psychologist_counselor_blog_args_');
                    $args = array(
                        'post_type'           => 'post',
                        'category_name'       => $psychologist_counselor_catergory_name,
                        'orderby'             => 'post__in',
                        'ignore_sticky_posts' => true,
                    );
                    ?>
                    <?php
                    $loop = new WP_Query($args);
                    if ( $loop->have_posts() ) :
                        $i=1;
                        while ($loop->have_posts()) : $loop->the_post(); ?>
                            <div class=" align-self-center px-0 position-relative">
                                <div class="box wow zoomInUp delay-1000" data-wow-duration="2s">
                                    <?php
                                        if ( has_post_thumbnail() ) : ?>
                                        <div class="image-blog">
                                          <?php the_post_thumbnail();?>
                                            <h4 class="title mb-2"><?php the_title();?></h4>
                                            <?php if( get_theme_mod( 'psychologist_counselor_category_designation'.$i ) != '' ) { ?>
                                                <span><?php echo esc_html(get_theme_mod('psychologist_counselor_category_designation'.$i)); ?></span>
                                            <?php } ?>
                                        </div>
                                        <?php else:
                                          ?>
                                          <div class="image-blog">
                                            <img src="<?php echo get_stylesheet_directory_uri() . '/images/default-header.png'; ?>">
                                            <h4 class="title mb-2"><?php the_title();?></h4>
                                            <?php if( get_theme_mod( 'psychologist_counselor_category_designation'.$i ) != '' ) { ?>
                                                <span><?php echo esc_html(get_theme_mod('psychologist_counselor_category_designation'.$i)); ?></span>
                                            <?php } ?>
                                          </div>
                                          <?php
                                        endif;
                                      ?>
                                    <div class="box-content mt-3">
                                        <h4 class="title mb-2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                        <?php if( get_theme_mod( 'psychologist_counselor_category_designation'.$i ) != '' ) { ?>
                                            <span><?php echo esc_html(get_theme_mod('psychologist_counselor_category_designation'.$i)); ?></span>
                                        <?php } ?>
                                        <p class="mb-0"><?php echo wp_trim_words( get_the_content(), 8 ); ?></p>
                                            <ul class="social">
                                                <?php 
                                                $psychologist_counselor_social_link1 = get_theme_mod( 'psychologist_counselor_social_link_1' . $i );
                                                $psychologist_counselor_social_link2 = get_theme_mod( 'psychologist_counselor_social_link_2' . $i );
                                                $psychologist_counselor_social_link3 = get_theme_mod( 'psychologist_counselor_social_link_3' . $i );
                                                $psychologist_counselor_social_link4 = get_theme_mod( 'psychologist_counselor_social_link_4' . $i );

                                                if ( ! empty( $psychologist_counselor_social_link1 ) ) {
                                                    echo '<li><a class="social1" href="' . esc_url( $psychologist_counselor_social_link1 ) . '" target="_blank"><i class="fab fa-facebook-f"></i></a></li>';
                                                }
                                                if ( ! empty( $psychologist_counselor_social_link3 ) ) {
                                                    echo '<li><a class="social3" href="' . esc_url( $psychologist_counselor_social_link3 ) . '" target="_blank"><i class="fab fa-instagram"></i></a></li>';
                                                }
                                                if ( ! empty( $psychologist_counselor_social_link2 ) ) {
                                                    echo '<li><a class="social2" href="' . esc_url( $psychologist_counselor_social_link2 ) . '" target="_blank"><i class="fab fa-twitter"></i></a></li>';
                                                } 
                                                if ( ! empty( $psychologist_counselor_social_link4 ) ) {
                                                    echo '<li><a class="social4" href="' . esc_url( $psychologist_counselor_social_link4 ) . '" target="_blank"><i class="fab fa-linkedin-in"></i></a></li>';
                                                }
                                                ?>
                                            </ul>
                                    </div>
                                </div>
                            </div>
                        <?php  $i++; endwhile;
                    endif;
                ?>
            </div>
        </div>
    </div>
</div>
<?php } ?>