<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package Travel Tour
 */

get_header();

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

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

  $content_column_class = 'col-md-9';
  $sidebar_left_class = 'col-md-3';
  $sidebar_right_class = 'col-md-3';

  if( $sidebar_layout == 'no-sidebar' ) {
      $content_column_class = 'col-md-12';
  }
?>
<?php if ( have_posts() ) { ?>

    <div class="my-64">
      <div class="container-xl">        
        <div class="row">
          
          <?php if( $sidebar_layout == 'left-sidebar' ) { ?>
            <div class="<?php echo esc_attr( $sidebar_left_class ); ?>"><?php get_sidebar(); ?></div>
          <?php } ?>
            
          <div class="d-flex flex-column <?php echo esc_attr( $content_column_class ); ?>">
            <?php $archive_title = get_theme_mod( 'blog_post_section_title' ); ?>
            <?php if( ! empty( $archive_title ) ) { ?><h1 class="mb-32"><?php echo esc_html( $archive_title ); ?></h1><?php } ?>
            <div class="w-p100 grid gap-20 gap-sm-40 overflow-hidden"> 
              
              <?php /* Start the Loop */ ?>
              <?php while ( have_posts() ) : the_post(); ?>
                  <?php
                    get_template_part( 'template-parts/content', null, array(
                      'view' => $view
                    ) );
                  ?>
              <?php endwhile; ?>                                       
              
              <?php wp_reset_postdata(); ?>
            </div>

            <?php travel_tour_pagination( $wp_query ); ?>
          
          </div>

          <?php if( $sidebar_layout == 'right-sidebar' ) { ?>
            <div class="<?php echo esc_attr( $sidebar_right_class ); ?>"><?php get_sidebar(); ?></div>
          <?php } ?>

        </div>
      </div>
    </div>
    
<?php } ?>
    

<?php get_footer();