<?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.
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package fatal
 */

	get_header();?>
	<!-- featured posts -->
	
	
     <div class="container">
	   <center><h2 class ="latest-posts"><span><?php _e( 'Featured Posts', 'fatal' ); ?></span></h2><h2 class="triangle"><span class="hide"><?php _e( 'test', 'fatal' ); ?></span></h2></center>

		<?php
		
	    //   adding fatured posts

		$args = array(
			'posts_per_page'  => 1,
			'posts_type'      => 'posts',
			);

			$my_fatal_query = new WP_Query($args);?>
			
		<?php
		
		if ($my_fatal_query->have_posts()):?>
		<div class="row custom-loop">
		
			<?php
			while($my_fatal_query->have_posts()): 
			$my_fatal_query->the_post(); ?>

			<div class="col-md-6 large-image grid">

				<figure> 
						<a href="<?php the_permalink(); ?>">
						<?php if(has_post_thumbnail()) : 
			                 the_post_thumbnail(); ?></a><?php
			                     else:?>
			              	<img src="<?php echo esc_url( get_template_directory_uri()."/img/thumbnail.jpg" ); ?>">
                <?php endif;?>
						<p class="category"><?php the_category(', '); ?></p>
						<div class="info">
								<h3>
								<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
								</h3>
						<p class="details"><a href="<?php the_author_posts() ?>"></a> 
						<?php echo get_the_date('F j, Y'); ?></p>
						</div><!--info-->
				</figure>
			

		 </div><!--col-md-6-->
		
				<?php
		    endwhile;
		  endif;
	    wp_reset_postdata();
	
	      /// adding second wpquery/grid post
		  $args = array(
			'posts_per_page'  => 4,
			'posts_type'      => 'posts',
			'offset'          => 1,
			);

			$my_fatal_grid_query = new WP_Query($args);?>

			<div class="col-md-6 post-grid">
			
		    <?php
		
					if ($my_fatal_grid_query->have_posts()):?>
					<div class="row">
		
					<?php
					while($my_fatal_grid_query->have_posts()): 
					$my_fatal_grid_query->the_post(); ?>

			 <div class="col-md-6 col-sm-12 grid posts-holder">

					<figure> 
							<a href="<?php the_permalink(); ?>">
							<?php if(has_post_thumbnail()) : 
			                   the_post_thumbnail(); ?></a><?php
			                      else:?>
			     	              <img src="<?php echo esc_url( get_template_directory_uri()."/img/thumbnail.jpg" ); ?>">
                                      <?php endif;?>
										<p class="category"><?php the_category(', '); ?></p>
										<div class="info">
										<h3>
										<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
										</h3>
										<p class="details"><a href="<?php the_author_posts() ?>"></a> 
							    <?php echo get_the_date('F j, Y'); ?></p>
							   </div><!--info-->
					</figure>
			

		    </div><!--col-md-6-->
		
		<?php
		endwhile;
		endif;
		wp_reset_postdata();?>

	  </div><!--col-md-6--post-grid-->

		
</div><!--row--->
</div><!---posts-holder--->
</div><!---container--->


   <div class="container col-md">
	<div class="row">
		<?php
	  $sidebar = get_theme_mod('fatal_sidebar_set', 'right');
	  if($sidebar == "left"){
	   get_sidebar();
	}?>
	<div class="col-md-9">
	<main id="primary" class="site-main">
	<h2 class ="latest-posts"><span><?php _e( 'Latest Posts', 'fatal' ); ?></span></h2><h2 class="triangle"><span class="hide-right-triangle"><?php _e( 'test', 'fatal' ); ?></span></h2>


		<?php
		if ( have_posts() ) :
			
			
			if ( is_home() && ! is_front_page() ) :
				
				?>
				
				<header>
					<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
				</header>
				<?php
			endif;

			/* Start the Loop */
			while ( have_posts() ) :
				the_post();

				/*
				 * Include the Post-Type-specific template for the content.
				 * If you want to override this in a child theme, then include a file
				 * called content-___.php (where ___ is the Post Type name) and that will be used instead.
				 */
				get_template_part( 'template-parts/content', get_post_type() );

			endwhile;

			the_posts_navigation();

		else :

			get_template_part( 'template-parts/content', 'none' );

		endif;
		?>

	</main><!-- #main -->
	</div><!--col-md--8-->

<?php
	if($sidebar == "right"){
		get_sidebar();
	}
		?>
		
</div><!--row-->
</div><!--container-->

<?php
get_footer();



