<?php
/**
 * The template for displaying archive pages
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package Sparta
 */

$sparta_blog_archive_style = get_theme_mod('sparta_blog_archive_style', 'list');

get_header(); ?>
    <section class="vk-content">
        <div class="vk-banner vk-background-image-1 page-title-bg">
            <div class="vk-background-overlay"></div>
            <div class="container ">
                <div class="vk-banner-wrapper">
                    <div class="page-heading">
                        <?php
                        the_archive_title('<h1 class="page-title">', '</h1>');
                        ?>
                    </div>
                    <div class="vk-breadcrumb">
                        <?php
                        Sparta_Core::get_sparta_template('breadcrumbs');
                        ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="vk-page blog blog-list">
            <div class="container">
                <div class="row">
                    <?php
                    if (is_active_sidebar('sidebar-1') && get_post_type() !== 'mphb_room_type') :
                        echo '<div class="col-lg-9">';
                    else:
                        echo '<div class="col-lg-12">';
                    endif;

                    if (have_posts()) :
                        /* Start the Loop */
                        global $post, $wp_query;

                        if (get_post_type() === 'mphb_room_type'):
                            $hotels_archive_style = get_theme_mod('sparta_hotels_archive_style', 'list');
                            ?>
                            <div class="vk-room-<?php echo esc_attr($hotels_archive_style); ?>-content">
                                <?php
                                if ($hotels_archive_style == 'grid') :
                                    echo '<div class="row vk-rooms-grid-content">';
                                    ?>
                                    <div class="vk-rooms-grid-header col-md-12">
                                        <h3><?php echo esc_html__('Our Rooms', 'sparta'); ?></h3>
                                        <h2><?php echo esc_html__('Choose Your Room', 'sparta'); ?></h2>
                                        <div class="vk-rooms-grid-border"></div>
                                    </div>
                                    <?php
                                endif;

                                while (have_posts()) : the_post();

                                    get_template_part('template-parts/hotel/' . $hotels_archive_style);

                                endwhile;

                                if ($hotels_archive_style == 'grid') :
                                    echo '</div>';
                                endif;
                                ?>
                            </div>
                        <?php
                        else:
                            ?>
                            <div class="vk-blog-list-body-content vk-blog-<?php echo esc_attr($sparta_blog_archive_style); ?>-content">
                                <?php
                                if ($sparta_blog_archive_style == 'grid') :
                                    echo '<div class="row">';
                                endif;
                                while (have_posts()) : the_post();

                                    get_template_part('template-parts/blog/' . $sparta_blog_archive_style);

                                endwhile;

                                if ($sparta_blog_archive_style == 'grid') :
                                    echo '</div>';
                                endif;
                                ?>
                            </div>
                        <?php
                        endif;

                        Sparta_Helper::sparta_paging_nav();
                    endif; ?>
                </div>
                <?php if (is_active_sidebar('sidebar-1') && get_post_type() !== 'mphb_room_type') : ?>
                    <div class="col-lg-3">
                        <?php get_sidebar(); ?>
                    </div>
                <?php endif; ?>
            </div>
        </div>
        </div>
    </section>
<?php
get_footer();
