<?php /*template name: List Sub Pages*/ get_header(); ?>

<div class="uk-container">
	<main role="main">
		<section>

			<h1><?php the_title(); ?></h1>

			<?php if (have_posts()): while (have_posts()) : the_post(); ?>

				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

					<?php the_content(); ?>
					
					<div class="uk-child-width-1-3@m uk-text-center uk-grid-small uk-margin-large-top" uk-grid> 
						
							<?php
							$id = get_the_ID();
							$args = array(
								'post_type'      => 'page',
								'posts_per_page' => -1,
								'post_parent'    => $id,
								'order'          => 'ASC',
								'orderby'        => 'menu_order'
							 );


							$parent = new WP_Query( $args );

							if ( $parent->have_posts() ) : ?>

								<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
								
								<div>
									<div id="parent-<?php the_ID(); ?>" class="parent-page uk-text-center">
										<div class="uk-inline-clip uk-transition-toggle">
											<div class="uk-text-center banner_small">
													<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
														<img class="uk-transition-scale-up uk-transition-opaque" src="<?php the_post_thumbnail_url('large'); ?>">
													</a>
												</div>
										</div>
										<div class="uk-text-center uk-margin">
											<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
											<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="black-btn uk-margin">Find Out More</a>
										</div>
									</div>
								</div>
		

								<?php endwhile; ?>

							<?php endif; wp_reset_postdata(); ?>
						
						</div>
					
					

					<br class="clear">

					<?php edit_post_link( __('Edit this page'), '', '', 0, 'post-edit-link uk-label uk-float-right' ); ?>

				</article>

			<?php endwhile; ?><?php endif; ?>

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