<?php
/**
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages and that
 * other "pages" on your WordPress site will use a different template.
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */

get_header(); ?>
	
	<?php
		// Start the loop.
	while ( have_posts() ) : the_post();

	echo '<h1 class="title">';
		h1_title();
	echo '</h1>';
		// Include the page content template.
		the_content();

	// End the loop.
	endwhile;
	?>

	<?php
		$grid_heading = get_field('grid_heading');
		if( $grid_heading ){
			echo '<h2>'.$grid_heading.'</h2>';
		}
	?>
	
	<?php if( have_rows('home_grid') ): ?>

		<div class="row">

			<?php while( have_rows('home_grid') ): the_row(); 

				// vars
				$grid_title = get_sub_field('grid_title');
				$grid_image = get_sub_field('grid_image');
				$grid_summary = get_sub_field('grid_summary');
				$grid_button_text = get_sub_field('grid_button_text');
				$grid_button_url = get_sub_field('grid_button_url');

				?>

				 <div class="col-xs-12 col-sm-6">
	                <div class="article">
	                    <h3 class="article-heading"><?php echo $grid_title; ?></h3>                            
	                    <div class="article-body">
	                    	<?php if( $grid_image ) : ?>
	                    		<div class="article-img">
		                            <img src="<?php echo $grid_image['url'] ?>" alt="<?php echo $grid_image['alt'] ?>" />
		                        </div>	
	                    	<?php endif; ?>                        
	                        <?php echo  $grid_summary; ?>
	                        <?php if( $grid_button_text ) :?>
	                        	<div class="btn-permalink text-center"><a href="<?php echo $grid_button_url; ?>" class="btn btn-xoxo"><i class="fa fa-play"></i> &nbsp; <?php echo $grid_button_text; ?></a></div>
	                        <?php endif; ?>   
	                        
	                    </div>
	                </div>
	            </div>

			<?php endwhile; ?>

		</div>

	<?php endif; ?>
<?php get_footer(); ?>
