<?php get_header(); ?>

<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$headerImg = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );

$showImage = "";

if(!empty($headerImg)) $showImage = 1;
if(!empty($image)) $showImage = 2;

 ?>

<?php $mt_page_title =  get_post_meta($post->ID, "mt_page_title", true); ?>

<section class="topSingleBkg topPageBkg <?php if(!empty($image) || !empty($headerImg)):?> topSingleBkgImg <?php endif;?>">  

<?php switch ($showImage):
		case '1': ?>
		  
			<div class="item-img" style="background-image:url('<?php echo esc_url($headerImg); ?>');"></div>
			   
		<?php break;
		case '2': ?>
		
			<div class="item-img" style="background-image:url('<?php echo esc_url($image[0]); ?>');"></div>
				
		<?php break; ?>
		       
		<?php endswitch; ?>

  <div class="inner-desc">	 
  
 <h1 class="post-title single-post-title"><?php if(!empty($mt_page_title)): echo esc_html($mt_page_title); else: the_title(); endif;?></h1>
 
</div>

</section>

<section id="wrap-content" class="page-content blog-post-single">

<div class="container">

<div class="row">

<?php if ( is_active_sidebar( 'sidebar-1' )): ?>

<div class="col-md-9 posts-holder">

<?php else: ?>

<div class="col-md-12 page-full">

<?php endif; ?>

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

<div id="post-<?php the_ID(); ?>" class="page-holder single-post-content custom-page-template clearfix">

<?php the_content(); ?>

</div>
<?php  endwhile;

else: ?>

<p class="alignc"><?php esc_html_e( 'Sorry, but it seems we can&rsquo;t find what you&rsquo;re looking for. Try the menu above.', 'liberis' ); ?></p>

<?php endif; ?>

<?php // 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; ?>

</div><!--col-md-9-->

<?php if ( is_active_sidebar( 'sidebar-1' )): ?>

			<?php get_sidebar(); ?>

			<?php endif; ?>

</div><!--row-->
</div><!--container-->
</section>

<?php get_footer(); ?>