<?php 
/**
 * The template for displays the search page
 *
 * @package WordPress
 * @subpackage Edition
 * @since Edition 1.0
 */
get_header();

global $tw_options;

// Get ID of posts page	
$pageID = get_option('page_for_posts');

// Get posts pack background
if ( $pageID != 0 ) :
	$thumb          = wp_get_attachment_image_src( get_post_thumbnail_id( $pageID ), 'fullsideshow' );
	$background_url = isset( $thumb['0'] ) ? $thumb['0'] : '';
else:
	$background_url = false;
endif; 
?>

<div class="pagewrapper no-background default-layout">
	<?php get_template_part('functions/templates/title-full'); ?>

	<div class="container">
		<div class="rightside">
			<div class="rightcontent regulargrid content">

				<!-- Regular Posts -->
				<div class="regularwrapper search-list">        
					<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
						<div class="search-item">

							<?php if ( $tw_options['search-images'] ) : ?>
								<div class="featuredimage">
									<?php the_post_thumbnail( 'contentslideshownc' ); ?>
								</div>
							<?php endif; ?>

							<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 the_time(get_option('date_format')); ?>
							</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>
					<?php endwhile; else : ?>

						<h4><?php _e('Search Again', 'themewich'); ?>:</h4>
						<p><?php get_search_form(true); ?></p>

					<?php endif;	// End Loop 
					wp_reset_query(); 	// Reset Query ?>
					
					<div class="clear"></div>
				
					<?php themewich_pagination(); ?>
				</div><!--.regularwrapper-->          
			</div><!--.rightcontent-->
			<div class="clear"></div>
		</div><!--.rightside-->

		<div class="sidebar">
			<div class="sidebarcontent">
				<?php dynamic_sidebar('Blog Sidebar'); ?>
            </div>
        </div>

    </div><!--.container-->
</div>

<?php get_footer(); 