<?php get_header(); 

?>

<section class="page-section main-content-section">
	<div class="container">
		<div class="row">
			<div class="col s12 m10 push-m1 l8 push-l2">
				<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>


						<div class="singular-header">
							<div class="single-header-post-type">
									<?php 
									$postType = get_post_type_object(get_post_type());
									if ($postType) {
									    echo esc_html($postType->labels->all_items);
									}
									?>
							</div>
							<a href="/explore" class="control control-back inverse icon-arrow-thin-left">
		                        <span>Back</span>
		                    </a>



						</div>

						<h1 class="center-align"><?php the_title(); ?></h1>

						<div class="single-post-feature-image nospace-mobile">
							<?php the_post_thumbnail();?>
						</div>
						
						<div class="index-content <?php if ( !== get_post()->post_content ) { echo ' plain_text'; } ?>">
							<?php the_content(); ?>



						</div>


					<?php if (get_post_type() == "post"): ?>
						<?php comments_template(); ?>
					<?php endif; ?> 

				<?php endwhile; else : ?>
					<p><?php _e( 'Sorry, nothing was found.' ); ?></p>
				<?php endif; ?>

			</div>


		</div> 
	</div>
</section>


<?php
	get_template_part('partials/template', 'pagesections'); 
?>



<?php if (get_post_type() == "news" or get_post_type() == "media"): ?>


	<!-- begin custom related loop, isa -->
	 
	<?php 
	global $post;
	$post_type = get_post_type();
	// arguments
	$args = array(
	'post_type' => $post_type,
	'posts_per_page' => 4,
	'post__not_in' => array ($post->ID)
	);
	$related_items = new WP_Query( $args );
	// loop over query
	if ($related_items->have_posts()) : ?>


		<section class="page-section related-posts style-med clearfix">
			<div class="section-inner card_grid">
			<div class="container">
				<h2 class="center-align">Explore more TAXONOMY TERM</h2>
				<div class="posts-grid">
						<?php while ( $related_items->have_posts() ) : $related_items->the_post();
						?>
							<?php get_template_part('partials/template', 'post-card'); ?>
						<?php
						endwhile;
					?>
				</div>
			</div>
			</div>
		</section>

	<?php endif;
	// Reset Post Data
	wp_reset_postdata();
	?>
	 
<?php endif; ?>


<?php get_footer(); ?>