<?php
/**
 * The template for displaying the full width post section.
 *
 * @package WordPress
 * @subpackage Edition
 * @since Edition 1.0
 */
global 
$tw_order_class,  // section order 
$tw_section,    // section object
$paged;       // pagination variable

$tw_section   	= themewich_section_object();     // section post options
$section_post   = $post; // Store Section Post

// Set post classes
$tw_section->post_classes  = array(
	'full-post',
	'section',
	$tw_order_class,
	$tw_section->title_class
); ?>

<div <?php post_class($tw_section->post_classes); ?>>

	<div class="container">
		<div class="col-md-12">
			<?php get_template_part( TW_SECTIONS_DIR .'/section-title'); // Section title ?>
		</div>
	</div>

	<div class="full-image-section">
		<?php themewich_section_edit(); // edit button ?>

			<?php 
				global $wp_query; // for pagination

				$i = 0; // counter

				global $post;
				
				// Additional query arguments
				$args = array(
					'ignore_sticky_posts'   => 1,   					// Ignore Sticky Posts
					'post_type'             => array( 'post' ), 		// Get posts
					'nopaging'				=> false,					// Use paging
					'paged'                 => 1,  						// Add pagination
					'posts_per_page'        => $tw_section->full_section_post_number, 	// Set posts per page
				);

				// Filter the latest posts by type chosen
				$args = themewich_post_args($args);

				wp_reset_query(); 					// Reset query
				$wp_query = new WP_Query($args); 	// Query the posts
		
				// Start the loop
				while ($wp_query->have_posts()) : $wp_query->the_post();  
			?>
			
		<?php 
			$feat_image 	= wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'fullslideshow' );
			$tw_categories 	= ag_get_cats_array(3);   // get all post categories
		?>

		<div class="fullsection <?php if ($i % 2 == 0) { echo 'even'; }  else { echo 'odd'; } ?> <?php if ( isset($tw_categories[0]->term_id) ) { echo 'highlight_category_' . $tw_categories[0]->term_id; } ?>">

			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="fullpostimage loading-dark">
				<div class="imagewrapper">
					<div class="imagecover">
	          			<img itemprop="photo" src="<?php echo isset($feat_image[0]) ? $feat_image[0] : ''; ?>"  class="top-bg-image"/>
	        			<?php echo themewich_review_circle('title', false); ?>
	        		</div>
        		</div>
			</a>

			<div class="container">
				<div class="fullcontent">
					<span class="badge">
						<?php echo ag_get_cats(3); ?>
					</span>
					<h2 class="title">
						<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
							<?php the_title(); ?>
						</a>
					</h2>
					<div class="tiny-details">
						<span class="author">
							<?php _e( 'By', 'themewich' );?> <span itemprop="author"><?php tw_author_link('posts'); ?></span>
						</span>
						<span class="tw-bullet">&nbsp;&bull;&nbsp;</span>
						<?php themewich_date('human'); ?>
					</div>
					<div class="regularcontent">
						<?php 
							global $more; $more = 0;
							if ( preg_match( '/<!--more/', $post->post_content ) ) {
								$content = apply_filters('the_content',get_the_content(__('Read More', 'themewich')));
								echo wp_kses_post( $content );
							} else {
								the_excerpt(__('Read More', 'themewich'));
							}
						?>
					</div>
				</div><!--.fullcontent-->
			</div>
	  	</div><!--.fullsection-->
	  
		<?php 
			$i++; 				// Increment Counter
			endwhile; 			// End Loop 
			wp_reset_query(); 	// Reset Query
		?>

		<div class="clear"></div>     
	</div><!--.full-image-section-->
</div><!--.homesection-->