<?php
/**
 * Page.php is used to render your regular pages.
 * @package Ultra WordPress Theme
 * @since 1.0
 * @author AJ Clarke : http://wpexplorer.com
 * @copyright Copyright (c) 2012, AJ Clarke
 * @link http://wpexplorer.com
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */

get_header(); // Loads the header.php template
if (have_posts()) : while (have_posts()) : the_post();  // Start loop - don't bother with anything if there isn't a post

	// Display page slider based on meta content
	get_template_part( 'content-page', 'slider' );
		
	// Show featured image
	if( has_post_thumbnail( get_the_ID() ) ) { ?>
		<div id="page-featured-img" class="boxed <?php if ( get_post_meta( get_the_ID(), 'wpex_page_featured_img_overlay', true ) !== '' ) echo 'with-overlay"'; ?>">
			<img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ),  wpex_img( 'page_width' ), wpex_img( 'page_height' ), wpex_img( 'page_crop' ) ); ?>" alt="<?php echo the_title(); ?>" />
			<?php
			// Featured Image Overlay
			if ( function_exists('wpex_featured_image_overlay') ) wpex_featured_image_overlay(); ?>
		</div><!-- #page-featured-img -->
	<?php }
	
	// Show header unless disabled via the custom field "wpex_page_disable_heading"
	if ( get_post_meta( get_the_ID(), 'wpex_page_disable_heading', true) !== 'yes' ) { ?>
		<header id="page-heading">
			<div class="boxed">
				<h1><?php the_title(); ?></h1>
				<?php
				// Yoast Breadcrumbs Support
				if( function_exists('yoast_breadcrumb') ) yoast_breadcrumb('<div id="breadcrumbs"><span class="icon-home"></span>','</div>'); ?>
			</div><!-- .boxed -->
		</header><!-- #page-heading -->
	<?php } ?>
	
	<div id="page-wrap" class="clearfix boxed container">
		<article id="post" class="clearfix">
			<div class="entry clearfix fitvids">
				<?php the_content(); ?>
			</div><!-- .entry .clearfix -->
			<?php wp_link_pages( array( 'before' => '<div class="page-links clearfix">', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
		</article><!-- #post -->
		<?php
		// Load sidebar if post isn't full-width
		if( get_post_meta( get_the_ID(), 'wpex_post_layout', true ) !== 'Full Width' ) {
			get_sidebar();
		} ?>
	</div><!-- #page-wrap -->

<?php
endwhile; endif; // End loop
$wpex_page_featured_img_overlay = NULL;
get_footer(); // Loads the footer.php file ?>