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

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

			<h1 class="blue uk-margin-large-top uk-margin-medium-bottom"><?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-2@m" uk-grid>
						<div>
							<?php
							gravity_form( 1, false, false, false, '', true );
							?>
						</div>
						<div>
							<h3 class="uk-margin-remove blue">WORK WITH US</h3>
							<h2 class="uk-margin-remove-top">Ready for a Cleaner Workplace?</h2>

							<P>Let us take care of the cleaning—so you can focus on growing your business.</P>
							<P>Contact Malibu Janitorial today for a free consultation or to request a personalized quote.</P>

						</div>
					</div>


					<h3 class="uk-margin-remove-bottom uk-margin-large-top uk-text-center blue">WHAT WE DO</h3>
					<h2 class="uk-text-center uk-margin-remove-top">Our Cleaning Services</h2>

					<div class="uk-child-width-1-3@m uk-margin-large-top" uk-grid uk-height-match="target: > div > div > div > .uk-card">

							<?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 ">
										<div>
					            <div class="uk-card uk-card-default uk-padding">
					              <?php if ($icon = get_field('icon')) : ?>
					                  <div class="service-icon uk-flex uk-flex-middle uk-flex-center"><?php echo $icon; ?></div>
					              <?php endif; ?>
					              <h3 class=""><a class="blue black-hov" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

					              <?php if ($short_desc = get_field('short_description')) : ?>
					                  <p><?php echo esc_html($short_desc); ?></p>
					              <?php endif; ?>
					            </div>
					          </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(); ?>
