<?php /*template name: List Sub Pages*/ get_header(); ?>
<?php if ( has_post_thumbnail() ) : ?> 
<div class="uk-cover-container uk-text-center banner uk-margin-large-bottom">
    <canvas class="uk-visible@m" width="" height="400"></canvas>
    <canvas class="uk-hidden@m" width="" height="600"></canvas>

	<img uk-img data-src="<?php the_post_thumbnail_url('full'); ?>" data-width data-height uk-cover>

	<div class="uk-overlay-primary uk-position-cover"></div>
	<div class="uk-position-cover uk-text-center uk-container uk-flex uk-flex-center uk-flex-middle">
        <div>
           <h1 class="white"><?php the_title(); ?></h1>
        </div>
    </div>
</div>
<?php endif; ?>
<div class="uk-container">
	<main role="main">
		<section>

			<?php if ( has_post_thumbnail() ) { ?> 
			<?php } else { ?>
				<h1 class="uk-text-center"><?php the_title(); ?></h1>
			<?php }?>

			<?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('thumbnail'); ?>">
													</a>
												</div>
										</div>
										<div class="uk-text-center uk-margin">
											<h2><a class="uk-text-decoration-none" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
										</div>
									</div>
								</div>
		

								<?php endwhile; ?>

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

					<br class="clear">

					<p class="uk-text-right"><?php edit_post_link( __('Edit this page'), '', '', 0, 'post-edit-link uk-text-large uk-padding-small uk-button-large uk-button uk-button-primary' ); ?></p>

				</article>

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

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