<?php 
/**
 * Template part for displaying Featured Classes Section
 *
 * @package House Rental
 */

$house_rental_classes = get_theme_mod( 'house_rental_classes_setting',false );
$house_rental_service_title = get_theme_mod( 'house_rental_service_title' );
$house_rental_service_text = get_theme_mod( 'house_rental_service_text' );

?>
<?php if ( $house_rental_classes ){?>
<div class="our-classes">
    <div class="container">
        <div class="service">
                    <div class="side-border">
                        <?php if ( $house_rental_service_text ){?>
                            <p class="title-text"><?php echo esc_html( $house_rental_service_text );?></p>
                        <?php } ?> 
                        <?php if ( $house_rental_service_title ){?>
                            <h3 class="mb-5"><?php echo esc_html( $house_rental_service_title );?></h3>
                        <?php } ?>                       
                    </div>
            <div class="owl-carousel">
                <?php 
                    $house_rental_catergory_name = get_theme_mod('house_rental_blog_args_');
                    $args = array(
                        'post_type'           => 'post',
                        'category_name'       => $house_rental_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">
                                <div class="box wow zoomIn delay-3000" data-wow-duration="3s">
                                    <?php
                                        if ( has_post_thumbnail() ) : ?>
                                        <div class="image-blog">
                                          <?php the_post_thumbnail();?>
                                          <div class="blog-title"><h5 class="title"><?php the_title();?></h5></div>
                                        </div>
                                        <?php else:
                                          ?>
                                          <div class="image-blog">
                                            <img src="<?php echo get_stylesheet_directory_uri() . '/images/default-header.png'; ?>">
                                            <div class="blog-title"><h5 class="title"><?php the_title();?></h5></div>
                                          </div>
                                          <?php
                                        endif;
                                      ?>
                                    <div class="box-content">
                                        <?php if( get_theme_mod( 'house_rental_category_icon'.$i ) != '' ) { ?>
                                            <span><i class="<?php echo esc_attr(get_theme_mod('house_rental_category_icon'.$i)); ?>"></i></span>
                                        <?php } ?>
                                        <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('Read More', 'house-rental'); ?></a>
                                        </p>
                                    </div>
                                </div>

                                </div>
                        <?php  $i++; endwhile;
                    endif;
                ?>
            </div>
        </div>
    </div>
</div>
<?php } ?>