<?php

/**
 * The default template for displaying pages
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 * @package Glaciers
 * @since 1.0.0
 */

if (!defined('ABSPATH')) {
	exit; // Exit if accessed directly.
}

get_header();
?>

<div class="container">
	<div class="row">
		<div class="col">

			<?php // Insert page featured image
			glaciers_post_thumbnail(); ?>

			<header id="page-header">
				<?php // Check if the Custom Heading field is available
				if (get_post_meta(get_the_ID(), 'Custom Heading', true)) {
					$meta_print_value = get_post_meta(get_the_ID(), 'Custom Heading', true);
					//echo($meta_print_value);
					echo '<div id="custom-page-heading">', wp_kses_post($meta_print_value) . '</div>';
					// Load the page excerpt if available
					if (has_excerpt() && !is_archive() && !is_search() && !is_404()) {
						echo '<div class="page-excerpt lead">', the_excerpt() . '</div>';
					}
					// Otherwise get the standard page heading
				} else {
					the_title('<h1 class="entry-title">', '</h1>');
					// Load the page excerpt if available
					if (has_excerpt() && !is_archive() && !is_search() && !is_404()) {
						echo '<div class="page-excerpt lead">', the_excerpt() . '</div>';
					}
				}


				?>
			</header><!-- .entry-header -->

		</div>
	</div>

	<div class="row">
		<div class="col-lg-8">
			<?php
			while (have_posts()) :
				the_post();

				get_template_part('template-parts/content', 'page');

				// If comments are open or we have at least one comment, load up the comment template.
				if (comments_open() || get_comments_number()) :
					comments_template();
				endif;

			endwhile; // End of the loop.
			?>
		</div>

		<aside class="widget-area blog-sidebar col-lg-4">
			<?php // Get our sidebar
			get_sidebar(); ?>
		</aside>

	</div>
</div>

<?php
get_footer();
