<?php
/*
Template Name: Home Page
*/
get_header(); ?>
<?php $front_placement=get_theme_mod('front_placement') ; ?> 
<?php  $choose_templatehome_sidebar=get_theme_mod('choose_templatehome_sidebar');?>
<?php  if($front_placement=='slider') { get_template_part('home', 'slider'); } else if($front_placement=='banner') { get_template_part('front', 'banner');  }?>
  <!--banner--><section id="content" class="wow fadeInUp">
<div class="container">
  <div class="row">
<?php if($choose_templatehome_sidebar=='left_blog' || $choose_templatehome_sidebar=='gridleft_blog'){?>
<aside class="col-md-4 col-sm-4 col-xs-12 left_sidebar">
    <?php get_sidebar(); ?>
    </aside>
<?php }?>
<?php if($choose_templatehome_sidebar=='full_blog' || $choose_templatehome_sidebar=='gridfull_blog'){
	$blogclass="col-md-12 col-sm-12 col-xs-12";
}
else
{
	$blogclass='col-md-8 col-sm-8 col-xs-12';
}
?>
   <?php 
   $grid=1;
  // set up or arguments for our custom query
  $paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
  $query_args = array('post_type'=>'post','posts_per_page'=>4,'order'=>'DESC','paged' => $paged);

  // create a new instance of WP_Query

  $the_query = new WP_Query( $query_args );
   
     if ($the_query->have_posts() ) : ?>
      <article class="<?php echo esc_attr($blogclass);?>">
            <div class="left-section wow fadeInUp">
    <?php while($the_query->have_posts()): $the_query->the_post(); 
	if(isset($choose_templatehome_sidebar)&&$choose_templatehome_sidebar=='gridleft_blog' || $choose_templatehome_sidebar=='gridright_blog' || $choose_templatehome_sidebar=='gridfull_blog')
	{
		get_template_part('template-parts/grid');
		if($grid++%2==0)
		{
			echo'<div class="clearfix"></div>';
		}
		$gridclass='templatehome_grid';
	}
	else
	{
		$gridclass='loadmore_post';
		
                get_template_part('template-parts/content', get_post_format() );
	}
	
            endwhile;
               ?>
          <!--entry--> 
      </div>
      <!--left-section-->
      <?php if ($the_query->max_num_pages > 1) {?>
         <div class="<?php echo esc_attr($gridclass);?>" max_page="<?php echo $the_query->max_num_pages?>" start_page="1"> 
         	<a class="btn btn-default" href="#"><?php esc_html_e('Load More Post', 'tribute'); ?><i aria-hidden="true" class="fa fa-angle-double-down"></i><i class="fa fa-refresh fa-spin"></i></a>
         </div>
         <?php }?>
    </article>    
        <?php endif; ?>
    
    <?php if($choose_templatehome_sidebar=='right_blog' || $choose_templatehome_sidebar=='gridright_blog'){?>
      <aside class="col-md-4 col-sm-4 col-xs-12">

    <?php get_sidebar(); ?>

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

  </section>
 <!--content-->

<?php get_footer(); ?>
