<?php /* Template Name: Our Team */ get_header(); ?>



<div class="uk-container" uk-scrollspy="cls: uk-animation-fade; delay: 200">
	<main role="main">
			<section>

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

				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
					<h1 class="uk-text-center"><?php the_title(); ?></h1>
					<?php the_content(); ?>
					
					<div class="uk-child-width-1-3@m uk-text-center uk-grid-small uk-margin-large-top" uk-grid uk-scrollspy="target: > div; cls: uk-animation-fade; delay: 200"> 
						
							<?php
							$args = array(
								'post_type'      => 'counsellors',
								'posts_per_page' => -1, // or a specific number
								'orderby'        => 'menu_order', // optional for manual sorting
								'order'          => 'ASC',
							 );


							$parent = new WP_Query( $args );

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

								<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
								
								<div>
	<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<div class="uk-card uk-card-default uk-card-body uk-box-shadow team-members uk-padding-remove uk-text-center">
				<?php if ( has_post_thumbnail() ) { ?>
					<div>
						<?php 
						$link = get_field('booking_link');
						if( $link ){ ?>
							<a href="<?php echo esc_url( $link ); ?>" target="_blank"><img uk-img data-src="<?php the_post_thumbnail_url('thumbnail'); ?>" data-width data-height></a>
						<?php } else { ?>
							<img uk-img data-src="<?php the_post_thumbnail_url('thumbnail'); ?>" data-width data-height>
						<?php }  ?>
					</div>
				<?php } else { ?>
				<?php } ?>
			<div class="uk-padding">
				<h2><?php the_title(); ?></h2>
				<p class="green"><?= get_field('job_title'); ?></p>
				<p><i>Enjoys Working with:</i></p>
				<?php

				// Check rows exists.
				if( have_rows('enjoys_working_with:') ): ?>
				
				<ul class="uk-text-left">
				
					<?php // Loop through rows.
					while( have_rows('enjoys_working_with:') ) : the_row(); ?>


						<li class="orange"><?= get_sub_field('item'); ?></li>


					<?php // End loop.
					endwhile; ?>
					
				</ul>

				<?php // No value.
				else :
					// Do something...
				endif; ?>
				<p class="orange"><?= get_field('counsellor_note'); ?></p>
				<p><?= get_field('counsellor_short_description'); ?></p>
				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="uk-button uk-button-primary">Read More</a>
			</div>
		</div>
	</article>		
</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(); ?>
