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

get_header();

$sidebar_layout = travel_tour_get_sidebar_layout();
$view = get_theme_mod( 'blog_post_view', 'list-view' );

if( $sidebar_layout == 'no-sidebar' ) {
  $content_column_class = 'col-md-12';
} else {
  $content_column_class = 'col-md-9';
}

global $wp_query;
$max_pages = $wp_query->max_num_pages;
?>

<div class="my-64">
  <div class="container-xl">
    <div class="row">

      <?php if ( $sidebar_layout == 'left-sidebar' ) : ?>
          <div class="col-md-3"><?php get_sidebar(); ?></div>
      <?php endif; ?>
        
      <div class="<?php echo esc_attr( $content_column_class ); ?>">

        <?php
        if( have_posts() ) :
          the_archive_title( '<h1 class="mb-32">', '</h1>' );
          the_archive_description( '<div class="mb-48">', '</div>' );
        endif;
        ?>

        <div class="w-p100 grid gap-20 gap-sm-40 overflow-hidden">
          <?php if ( have_posts() ) : ?>
          <?php while ( have_posts() ) : the_post(); ?>
            <?php
              get_template_part( 'template-parts/content', null, array(
                'view' => $view
              ) );
            ?>
          <?php endwhile; ?>

          <?php else : ?>
            <?php get_template_part( 'template-parts/content', 'none' ); ?>
          <?php endif; ?>
        </div>

        <?php travel_tour_pagination( $wp_query ); ?>

      </div>  
     
      <?php if( $sidebar_layout == 'right-sidebar' ) : ?>
          <div class="col-md-3"><?php get_sidebar(); ?></div>
      <?php endif; ?>

    </div>
  </div>
</div>
<?php get_footer(); ?>
